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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s