usaco Your Ride Is Here

/*
ID: modengd1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    ofstream fout ("ride.out");
    ifstream fin ("ride.in");
    string S1,S2;
    int modS1,modS2;
    while(fin >> S1>>S2)
    {
        modS1=1;modS2=1;
        for(int i=0;i<S1.size();i++)
            modS1=(modS1*(S1[i]-'A'+1))%47;
        for(int i=0;i<S2.size();i++)
            modS2=(modS2*(S2[i]-'A'+1))%47;
        if(modS1==modS2)
            fout<<"GO"<<endl;
        else
            fout<<"STAY"<<endl;
    }
    return 0;
}

  

posted on 2015-08-25 22:59  insaneman  阅读(161)  评论(0)    收藏  举报

导航