Created
July 10, 2015 06:54
-
-
Save insaneyilin/108494909811481f6bda to your computer and use it in GitHub Desktop.
My USACO solutions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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