Sunday, July 6, 2014

usaco Your ride is here solution

usaco Your ride is here:

usaco Your ride is here solution: http://ideone.com/GmGx8J


/*
ID: [your usacogate ID here]
PROG: ride
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    freopen("ride.in", "r", stdin);
    freopen("ride.out", "w", stdout);
    char a[10], b[10];
    int c=1, d=1;
    scanf("%s\n%s", a, b);
    for(int i=0; i<strlen(a); i++) c*=a[i]-'A'+1;
    for(int i=0; i<strlen(b); i++) d*=b[i]-'A'+1;
    c%=47, d%=47;
    if(c==d) printf("GO\n");
    else printf("STAY\n");
    return 0;
}

note: just comment freopen() to test it in ideone

1 comment: