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

输入格式:

第1行:一个长度为111到666的大写字母串,表示彗星的名字。

第2行:一个长度为111到666的大写字母串,表示队伍的名字。

输出格式:

如果能搭配,就输出“GO”,否则输出“STAY”。小组名和彗星名均是没有空格或标点的一串大写字母(不超过666个字母)。

直接上代码:

#include<iostream>
using namespace std;
int main() {
    char a[8], b[8];
    cin >> a;
    cin >> b;
    int sum1 = 1;
    int sum2 = 1;
    for (int i = 0; a[i]; i++) {
        sum1 *= (a[i] - 65 + 1);
    }
    for (int i = 0; b[i]; i++) {
        sum2 *= (b[i] - 65 + 1);
    }
    sum1 %= 47;
    sum2 %= 47;
    if (sum1 == sum2) {
        cout << "GO";
    }
    else {
        cout << "STAY";
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/hsjj/p/P1200.html