今天终于注册了USACO的账号,进入后发现这个OJ非常的神奇。所以特意在这篇文章中了解一下(本文以第一题作为例题讲解这个神奇OJ的不同之处)

正根。

       

详解USACO这个神奇的OJ_c++

       后面这些东西随便填不填。

       

详解USACO这个神奇的OJ_ide_02

       点击submit,就会发邮件到你填入的邮箱里。告诉你UserName和Password。

       

详解USACO这个神奇的OJ_#include_03

       填入上面的框框中就进入网站了,但之后可以在网站上方6个蓝色条第一列最后一条Change Password改成自己心仪的密码方便记忆哦。

       下图就是网站主页了。中间的表格就是一道道题目,必须把一个Section解决才能进入下一个Section。我们看到标题前有TEXT就是文章,看完就可以了,PROB就是需要做的题目。标题前会有标记和完成日期。DONE表示已完成,VIEWED表示正在进行中,TODO表示还没有做过。左边一栏NEWS中的第一条就是USACO的Contest(比赛)啦,有兴趣的人可以自己去打一打。

  

详解USACO这个神奇的OJ_ide_04

       进入题目!!!正式看到USACO的神奇之处。

       首先,是必须要选择文件上交!

       

详解USACO这个神奇的OJ_c++_05

       这很正常,但是它还规定了文件名,要把文件输入输出写出来。

       例如第一题要求你文件名ride。

       

详解USACO这个神奇的OJ_ide_06

       你要建一个文件

详解USACO这个神奇的OJ_#include_07

,输入输出

详解USACO这个神奇的OJ_#include_08

写好。       然后就是最重要的地方,我们需要在程序的最上方加入三行

详解USACO这个神奇的OJ_#include_09

。第一行ID就是你自己的UserName。第二行就是语言(其中C++11和C++14都是最新版的)。第三行是它给定的题目名。

       其实这一些在第一篇TEXT Submitting Solutions中都有写到,只是我觉得它写得不太易懂,故作此文。

       那么接下来正式看看第一题好了。

 

Your Ride Is Here

 

It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.

Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that "a mod b" is the remainder left over after dividing a by b; 34 mod 10 is 4.)

Write a program which reads in the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, printing "GO" if they match and "STAY" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.

Examples:

Input

Output

COMETQ
HVNGAT

GO

ABSTAR
USACO

STAY

PROGRAM NAME: ride

This means that you fill in your header with:
PROG: ride 
WARNING: You must have 'ride' in this field or the wrong test data (or no test data) will be used.

INPUT FORMAT

Line 1:

An upper case character string of length 1..6 that is the name of the comet.

Line 2:

An upper case character string of length 1..6 that is the name of the group.

NOTE: The input file has a newline at the end of each line but does not have a "return". Sometimes, programmers code for the Windows paradigm of "return" followed by "newline"; don't do that! Use simple input routines like "readln" (for Pascal) and, for C/C++, "fscanf" and "fid>>string".

NOTE 2: Because of the extra characters, be sure to leave enough room for a 'newline' (also notated as '\n') and an end of string character ('\0') if your language uses it (as C and C++ do). This means you need eight characters of room instead of six.

SAMPLE INPUT (file ride.in)

COMETQ
HVNGAT

OUTPUT FORMAT

A single line containing either the word "GO" or the word "STAY".

SAMPLE OUTPUT (file ride.out)

GO

OUTPUT EXPLANATION

Converting the letters to numbers:

 

C

O

M

E

T

Q

 

3

15

13

5

20

17

 

 

H

V

N

G

A

T

8

22

14

7

1

20

 

then calculate the product mod 47:

3 * 15 * 13 * 5 * 20 * 17 = 994500 mod 47 = 27
8 * 22 * 14 * 7 * 1 * 20 = 344960 mod 47 = 27

Because both products evaluate to 27 (when modded by 47), the mission is 'GO'. 


Submit a solution:

 

 


​Training Gateway​​  |   ​​Comment or Question​​


       题意比较简单,两个单词,根据题意将每个单词分别转化为数字,如果两个数字对47取模相同输出“GO”,否则输出“STAY”。直接模拟。

Code:

/*
ID:jackora1
LANG:C++
TASK:ride
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define N 1005
using namespace std;
char a[N],b[N];
int main()
{
freopen("ride.in","r",stdin);
freopen("ride.out","w",stdout);
scanf("%s%s",a,b);
long long ans1=1,ans2=1;
for(int i=0;i<strlen(a);i++)ans1*=(long long)a[i]-'A'+1;
for(int i=0;i<strlen(b);i++)ans2*=(long long)b[i]-'A'+1;
if((ans1%47)==(ans2%47))puts("GO");else puts("STAY");
return 0;
}

       在你A了一道题后,它会给你题解(ANALYSIS)。但这似乎没什么用。

 

       

详解USACO这个神奇的OJ_c++_10

       好了,关于USACO的讲解就结束了。Thank you all!