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

你的飞碟在这儿

难度:☆

Code:

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int jisuan(char a[]);
int main() {
    char a[7] = {};
    char b[7] = {};
    cin>>a;
    cin>>b;
    int C = jisuan(a);
    int D = jisuan(b);
    if(C == D)
        cout<<"GO"<<endl;
    else
        cout<<"STAY"<<endl;
    return 0;
}

int jisuan(char a[])
{	int sum = 1;
    for(int i = 0; i < strlen(a); i++) {
        if(a[i] == 'A')
            sum = sum % 47;
        else
            sum = sum * (a[i] - 'A' + 1) % 47;
    }
        return sum;
}
posted @ 2019-05-30 20:11  Mystery_Sky  阅读(151)  评论(0编辑  收藏  举报