解题思路:
先说本题题干给出的说明非常清晰,对于细节的阐述非常明确,这样的题是真正的好题。本题相对简单,主要考察数组的使用、字符和数字的转换,根据题意,我们分别求出小组名和彗星名的数字,然后,利用分支去判断是否匹配。
参考程序:
#include<iostream>
using namespace std;
int main(){
string comet,group,res = "STAY";
int cometValue = 1,groupValue = 1;
cin>>comet>>group;
for(int i = 0;i < comet.length();i++){
cometValue *= comet[i] - 'A' + 1;
}
for(int i = 0;i < group.length();i++){
groupValue *= group[i] - 'A' + 1;
}
//彗星和小组进行匹配
if(cometValue % 47 == groupValue % 47)
res = "GO";
cout<<res;
return 0;
}
程序结果: