USACO 1.1 Your Ride Is Here
直接模拟
#include<cstdio> #include<cstring> using namespace std; #define MAXN 10 #define MOD 47 char s[MAXN],t[MAXN]; int main() { scanf("%s %s",s+1,t+1); int l1=strlen(s+1),l2=strlen(t+1),s1=1,s2=1; for(int i=1;i<=l1;i++) s1=s1*(s[i]-'A'+1)%MOD; s1%=MOD; for(int i=1;i<=l2;i++) s2=s2*(t[i]-'A'+1)%MOD; s2%=MOD; if(s1==s2) printf("GO\n"); else printf("STAY\n"); return 0; }
转载请注明出处,有疑问欢迎探讨
博主邮箱 2775182058@qq.com