USACO/Your Ride Is Here

USACO/Your Ride Is Here

Posted by dym on February 15, 2014

本文迁移自老博客,原始链接为 https://seven.blog.ustc.edu.cn/usacoyour-ride-is-here/

usaco的第一个题,不需要什么技巧。熟悉一下输入输出。

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

long long work(string tmp)
{
    int i = 0;
    long long ans = 1;
    int len = tmp.size();
    while(i < len)
    {
        ans = ans * (tmp[i] - 'A' + 1);
        i++;
    }
    return ans;
}
int main() {
    ofstream fout ("ride.out");
    ifstream fin ("ride.in");
    string a,b;
    fin>>a;
    fin>>b;
    if((work(a)%47) == (work(b)%47))
        fout<<"GO"<<endl;
    else
        fout<<"STAY"<<endl;
    return 0;
}