USACO Training Section 1.1 Your Ride Is Here

今天开始刷 USACO 的题目。为 NOIP 2012 奋斗!!!

很简单的模拟。代码如下:

#include <fstream>
#include <cstring>

using namespace std;

int main()
{
    ifstream fin ("ride.in");
    ofstream fout ("ride.out");
   
    string s1, s2;
    string::size_type i;
    int r1 = 1, r2 = 1;
   
    fin >> s1 >> s2;
    for (i = 0; i != s1.size(); i++)
    {
        int a = (int) s1[i];
        a = 26 - (90 - a);
        r1 *= a;
    }
    for (i = 0; i != s2.size(); i++)
    {
        int a = (int) s2[i];
        a = 26 - (90 - a);
        r2 *= a;
    }
    if ((r1 % 47) == (r2 % 47))
        fout << "GO" << endl;
    else
        fout << "STAY" << endl;
   
    fin.close();
    fout.close();
   
    return 0;
}

你可能感兴趣的:(USACO Training Section 1.1 Your Ride Is Here)