求助!!!!!!!!!!

P1200 [USACO1.1] 你的飞碟在这儿 Your Ride Is Here

```cpp #include <bits/stdc++.h> using namespace std; int main() { string n,m; cin>>n>>m; long long cnt1=1,cnt2=1; for(int i=0;i<6;i++) { if(i<n.length()) cnt1*=n[i]-64; if(i<m.length()) cnt2*=m[i]-64; } cnt1%=47; cnt2%=47; if(cnt1==cnt2) { cout<<"GO"; } else { cout<<"STAY"; } return 0; } ```
by fjh0531 @ 2023-10-31 20:29:16


cnt2不是2 考虑字符串不足6位
by fjh0531 @ 2023-10-31 20:30:18


首先,第一个问题,$cnt2$ 的初始值累乘不能为 $2$,要为 $1$(像 $cnt1$ 一样)。 第二个问题,不一定是所有的长度都是 $6$,所以你可以两个循环,或者 `if(i<n.size()) cnt1*=n[i]-64;`(可以见首个发回帖的人)。
by 2021zjhs005 @ 2023-10-31 20:31:37


@[fjh0531](/user/952663) 非常感谢!
by kevin_guoguo @ 2023-10-31 20:37:25


@[2021zjhs005](/user/1121995) 非常感谢
by kevin_guoguo @ 2023-10-31 20:38:05


|