-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUSACO2.java
61 lines (45 loc) · 1.24 KB
/
USACO2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
ID: achyuta2
LANG: JAVA
TASK: ride
*/
import java.io.*;
import java.util.*;
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")));
int [] digits = {1,1,1,1,1,1};
String t = f.readLine();
int n=0;
while(n<t.length()) {
int i =((int)t.charAt(n)) - 64;
digits[n] =i;
n+=1;
}
int pro1 = 1;
for (int x = 0; x < digits.length; x++){
pro1 = pro1 * digits[x];
}
int ans1 = pro1 % 47;
int [] digits1 = {1,1,1,1,1,1};
int s=0;
String r= f.readLine();
while(s<r.length()) {
int y =((int)r.charAt(s)) - 64;
digits1[s] =y;
s+=1;
}
int pro2 = 1;
for (int b = 0; b < digits1.length; b++){
pro2 = pro2 * digits1[b];
}
int ans2 = pro2 % 47;
if (ans2 == ans1){
out.println("GO");
} else{
out.println("STAY");
}
out.close();
}
}