Chapter 1:1.Your Ride Is Here

原创 2008年10月01日 17:12:00

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.


Input Output



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".




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

SAMPLE OUTPUT (file ride.out)



ID: Ritain He
PROG: ride

using namespace std;

const int ModNum = 47;
const int ArrLength = 7;

int GetMod(const char arr[])
    int i,sum = 1,num;
    for(i=0;(i<ArrLength) && ('/0' != arr[i]);i++)
        num = arr[i] - 'A' + 1;
        sum *= num;
    //cout<<sum % ModNum<<endl;   
    return sum % ModNum;
int main()
    ifstream fin ("");
    ofstream fout ("ride.out");

    char comet[ArrLength],group[ArrLength];
    if(GetMod(comet) == GetMod(group))
    return 0;

USACO: 1.1.1 Your Ride Is Here (ride) 解析!

Your Ride Is Here (ride) 这是USACO整个题库中最简单的一个问题,不需要特殊的算法和技巧。但一定要注意输入输出,一次读入两个字符串,以及判断文件结束。26^6,不存在...
  • E_pen
  • E_pen
  • 2013年10月02日 10:51
  • 1360

usaco 180 -- Your Ride Is Here

/* ID:18724601 LANG:C++ TASK:ride */ #include #include #include using namespace std; char str1[10],s...
  • u011346442
  • u011346442
  • 2015年01月23日 00:05
  • 199

USACO1.1 PROB Your Ride Is Here 比较分析

PROB Your Ride Is Here 有些星星上会有UFO来接地球人上去玩,但是这个UFO一次只能有一组人过去。所以要让这组人知道他们被选中了。方法是这样的,星星的名字和组名能确定一个小组该去...
  • niskoy
  • niskoy
  • 2015年12月15日 21:17
  • 361

UASCO Your Ride Is Here

题目原址: Your Ride Is HereYour Ride Is HereIt is a well-known fact that behind every good comet is a...
  • taul_
  • taul_
  • 2016年02月21日 19:51
  • 152

解题报告:USCAO第一题:your ride is here

题目的翻译这里就不再多说了,相信这对大家来说不是问题。第一题的考点我个人觉得如下:        1:字符串的处理,要输入两个不超过6的字符串而且要逐个处理,还是用C++中的string方便,因为我觉...
  • u010183966
  • u010183966
  • 2013年05月23日 08:32
  • 704

ytu 1401: 1.1.1Your Ride Is Here 你的飞碟在这儿!

1401: 1.1.1Your Ride Is Here 你的飞碟在这儿!Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 102  Solved: 44...
  • wzy_112099
  • wzy_112099
  • 2016年03月08日 08:34
  • 168

USACO——Your Ride Is Here 你的飞碟在这儿

描述 众所周知,在每一个彗星后都有一只UFO。这些UFO时常来收集地球上的忠诚支持者。不幸的是,他们的飞碟每次出行都只能带上一组支持者。因此,他们要用一种聪明的方案让这些小组提前知道谁会被彗星带...
  • qzhhehe
  • qzhhehe
  • 2015年04月05日 22:07
  • 354

USACO1.1.1 Your Ride Is Here (ride)

入门基础题,从头扫到尾即可 注意边乘边模。 /* ID:shijiey1 PROG:ride LANG:C++ */ #include #include #include using na...
  • u011265346
  • u011265346
  • 2014年12月10日 08:00
  • 287

USACO Your Ride Is Here 解题日志

这是我第一次在USACO上做题,学会怎么提交就弄了半天,感觉被自己蠢哭了。后来才发现文件一直没修改过来,囧啊囧。 题目很简单: Your Ride Is Here It ...
  • IAmTrash7
  • IAmTrash7
  • 2016年01月28日 22:57
  • 678

Your Ride Is Here

Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co...
  • billoshi
  • billoshi
  • 2007年04月18日 21:42
  • 365
您举报文章:Chapter 1:1.Your Ride Is Here