(USACO) Your Ride Is Here - Solution
import java.io.*;
import java.util.*;
class ride {
public static String alphabet = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
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 comet = f.readLine();
String group = f.readLine();
int cometResult = 1;
int groupResult = 1;
for (int i = 0; i < comet.length(); i++) {
cometResult *= alphabet.indexOf(comet.charAt(i));
}
for (int i = 0; i < group.length(); i++) {
groupResult *= alphabet.indexOf(group.charAt(i));
}
String result = "STAY";
if (cometResult%47 == groupResult%47) {
result = "GO";
}
out.println(result);
out.close();
}
}
import java.util.*;
class ride {
public static String alphabet = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
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 comet = f.readLine();
String group = f.readLine();
int cometResult = 1;
int groupResult = 1;
for (int i = 0; i < comet.length(); i++) {
cometResult *= alphabet.indexOf(comet.charAt(i));
}
for (int i = 0; i < group.length(); i++) {
groupResult *= alphabet.indexOf(group.charAt(i));
}
String result = "STAY";
if (cometResult%47 == groupResult%47) {
result = "GO";
}
out.println(result);
out.close();
}
}
Comments
Post a Comment