Skip to content

Instantly share code, notes, and snippets.

@insaneyilin
Created July 10, 2015 06:54
Show Gist options
  • Save insaneyilin/108494909811481f6bda to your computer and use it in GitHub Desktop.
Save insaneyilin/108494909811481f6bda to your computer and use it in GitHub Desktop.
My USACO solutions
/*
ID: yilin.g1
PROG: ride
LANG: C++
*/
/*
Your Ride Is Here
http://train.usaco.org/usacoprob2?a=1riZcYaDeJF&S=ride
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ofstream fout ("ride.out");
ifstream fin ("ride.in");
string s1, s2, mission;
fin >> s1 >> s2;
long long n1 = 1, n2 = 1;
for (int i = 0; i < s1.length(); ++i) {
n1 *= static_cast<long long>(s1[i] - 'A' + 1);
}
for (int i = 0; i < s2.length(); ++i) {
n2 *= static_cast<long long>(s2[i] - 'A' + 1);
}
mission = (n1 % 47 == n2 % 47) ? "GO" : "STAY";
fout << mission << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment