题解 P1200 【[USACO1.1]你的飞碟在这儿Your Ride Is He…】正常题解

jianzihao

2018-09-30 09:49:53

Solution

``` #include<iostream> #include<bits/stdc++.h> using namespace std; int main() { char a[10]; char b[10];//定义字符数组 cin>>a; cin>>b; int x[10]; int y[10];//定义与之对应的数组 int e=strlen(a); int f=strlen(b);//获取长度 int xj=1,yj=1; for(int i=0;i<e;i++) { x[i]=a[i]-'A'+1; xj*=x[i]; } xj=xj%47; for(int j=0;j<f;j++) { y[j]=b[j]-'A'+1; yj*=y[j]; } yj=yj%47;//判断,得到模47后的数 if(xj==yj) { cout<<"GO"; } else { cout<<"STAY"; }//最后判断能否带走 return 0; } ```