USACO Your Ride Is Here

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
ID: wcr19961
PROG: ride
LANG: C++11
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 7;
const int mod = 47;
char a[maxn], b[maxn];
int main() {
freopen("ride.in", "r", stdin);
freopen("ride.out", "w", stdout);
scanf("%s%s", a, b);
int len1 = int(strlen(a)), len2 = int(strlen(b));
int cnt1 = 1, cnt2 = 1;
for (int i = 0; i < len1; ++i) {
cnt1 *= a[i] - 'A' + 1;
}
for (int i = 0; i < len2; ++i) {
cnt2 *= b[i] - 'A' + 1;
}
puts(cnt1 % mod == cnt2 % mod ? "GO" : "STAY");
return 0;
}

支付宝扫码领红包