【USACO】【section1.1】Your Ride Is Here

时间:2022-06-28 14:41:19

以前的账号忘记了,只能从头了。

入门题不解释,就是sumg和sumc初始值置1不能置0。开始享用一个循环计算出sumg和sumc,其实两个数组最大程度为6,节省不了什么时间。

 1 /*ID:Moment1991
 2 PROG:ride
 3 LANG:C++
 4 */
 5 #include <iostream>
 6 #include <fstream>
 7 using namespace std;
 8 
 9 int main()
10 {
11     ifstream cin("ride.in");
12     ofstream cout("ride.out");
13     char comet[10];
14     char group[10];
15 
16     cin >> comet;
17     cin >> group;
18 
19     int i = 0;
20     long int sumc = 1,sumg = 1;
21     while(comet[i] != '\0')
22     {
23         sumc = sumc * (comet[i] - 'A' + 1);
24         i++;
25     }
26     i = 0;
27     while(group[i] != '\0')
28     {
29         sumg = sumg * (group[i] - 'A' + 1);
30         i++;
31     }
32     if(sumg%47 == sumc%47)
33         cout <<"GO"<<endl;
34     else
35         cout <<"STAY"<<endl;
36 }