50分,大犇帮助一下

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

请不要用Markdown语法来强调头文件的重要性。
by Smile_Cindy @ 2019-06-01 18:32:22


~~大犇求助~~
by sunyu0714 @ 2019-06-01 18:39:31


@[sunyu0714](/space/show?uid=197224) 题目给出的两个字符串长度最高为6,不是一定为6 ```cpp for (int i = 0; i < star.size(); i++) { x[i] = star[i] - 'A' + 1; } for (int j = 0; j < group.size(); j++) { sd[j] = group[j] - 'A' + 1; } ```
by 吴勉之 @ 2019-06-01 18:51:04


```cpp a2 = x[0] * x[1] * x[2] * x[3] * x[4] * x[5]; //改为a1 b2 = sd[0] * sd[1] * sd[2] * sd[3] * sd[4] * sd[5]; //改为b1 a2 = a1 % 47; b2 = b1 % 47; ```
by 吴勉之 @ 2019-06-01 18:55:59


@[sunyu0714](/space/show?uid=197224) 又试了一下,你的代码很多错…… 最好还是改成这样: ```cpp #include<iostream> #include<string> #include<cstdio> #include<cmath> using namespace std; int main() { string star; string group; int a1=1,b1=1,a2,b2,x[6],sd[6];//注意初始化为1 cin>>star; cin>>group; for(int i=0;i<star.size();i++) { x[i] = star[i] - 'A' + 1; a1 *= x[i]; } for (int j = 0; j < group.size(); j++) { sd[j] = group[j] - 'A' + 1; b1 *= sd[j]; } a2 = a1 % 47; b2 = b1 % 47; if (a2 == b2) { cout << "GO"; } else { cout << "STAY"; } return 0; } ```
by 吴勉之 @ 2019-06-01 19:05:10


```cpp #include <iostream> #include <iomanip> #include <algorithm> #include <string> using namespace std; int main() { std::string group, ufo; cin >> group >> ufo; int grp = 1, ufo_ = 1; for (char c : group) grp *= c - 'A' + 1; for (char c : ufo) ufo_ *= c - 'A' + 1; if (grp % 47 == ufo_ % 47) cout << "GO"; else cout << "STAY"; } ```
by haoxingxing @ 2019-06-08 10:14:08


|