70分求助

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

这道题的数据不一定是长度为7的字符串,试试用 gets读入,strlen得出长度
by 200610311a @ 2020-02-20 13:54:38


@[200610311a](/user/176012) gets不会有问题吗? ~~直接输入字符串~~
by __LePetitPrince__ @ 2020-02-20 14:12:58


```cpp #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std; string m,n; int sm = 1,sn = 1; int main () { cin >> m >> n; for (int i = 0; i < m.size(); i++) sm *= (int) (m[i] - 64); for (int i = 0; i < n.size(); i++) sn *= (int) (n[i] - 64); sm %= 47;sn %= 47; if (sm == sn) cout << "GO"; else cout << "STAY"; return 0; } ```
by __LePetitPrince__ @ 2020-02-20 14:14:34


谢谢各位dalao
by cleverxia @ 2020-02-20 18:53:26


@[XTH号游侠](/user/255169) 为什么都是输出STAY
by ytyuhuan @ 2020-02-23 23:01:26


@[XTH号游侠](/user/255169) ```cpp #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std; string m,n; int sm,sn=1; int main() { cin>>m>>n; for(int i=0;i<m.size();i++) sm*=(int)(m[i]-64); for(int i=0;i<n.size();i++) sn*=(int)(n[i]-64); sm%=47; sn%=47; if(sm==sn) cout<<"GO"<<endl; else cout<<"STAY"<<endl; return 0; }
by ytyuhuan @ 2020-02-23 23:09:48


@[XTH号游侠](/user/255169) 问题解决了,谢谢
by ytyuhuan @ 2020-02-23 23:22:52


|