Skip to content

Instantly share code, notes, and snippets.

@sharno
Created February 5, 2014 23:22
Show Gist options
  • Save sharno/8835448 to your computer and use it in GitHub Desktop.
Save sharno/8835448 to your computer and use it in GitHub Desktop.
USACO your ride is here solution
/*
ID: sharnob1
LANG: JAVA
PROG: ride
*/
import java.io.*;
class ride {
public static void main (String [] args) throws IOException {
BufferedReader f = new BufferedReader(new FileReader("ride.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ride.out")));
String a = f.readLine();
String b = f.readLine();
String ref = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int apro = 1, bpro = 1;
for (int i = 0; i < a.length(); i++) apro *= ref.indexOf(a.charAt(i));
for (int i = 0; i < b.length(); i++) bpro *= ref.indexOf(b.charAt(i));
if (apro % 47 == bpro % 47) out.println("GO"); else out.println("STAY");
out.close();
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment