USACO : Your Ride Is Here


/*
Link : http://train.usaco.org/usacoprob2?a=3rv4k6xDvNx&S=ride
*/

/*
PROG: ride
LANG: C++
*/

#include <bits/stdc++.h>

#define ll long long
#define SZ(a) a.size()

using namespace std;

int main()
{
    freopen("ride.in","r",stdin);
    freopen("ride.out","w",stdout);
    string str1,str2;
    ll a=1,b=1;
    cin>>str1>>str2;
    for(int i=0;i<SZ(str1);i++)
    {
        a=((a%47)*(str1[i]-'A'+1)%47)%47;
    }

    for(int i=0;i<SZ(str2);i++)
    {
        b=((b%47)*(str2[i]-'A'+1)%47)%47;
    }

    if(a==b)
        cout<<"GO"<<endl;
    else
        cout<<"STAY"<<endl;
    return 0;
}

Advertisements