Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: woonie1
- LANG: JAVA
- PROG: ride
- */
- import java.io.*;
- import java.lang.*;
- import java.util.*;
- /**
- * Note that Java console applications need to be run through the java runtime
- * by running "java -jar JarFile.jar" in the command line.
- * Java console applications can not be previewed in the Compilr IDE, only applets can.
- */
- class ride {
- public static void main (String [] args) throws IOException {
- // Use BufferedReader rather than RandomAccessFile; it's much faster
- BufferedReader f = new BufferedReader(new FileReader("ride.in"));
- // input file name goes above
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ride.out")));
- // Use StringTokenizer vs. readLine/split -- lots faster
- StringTokenizer s1 = new StringTokenizer(f.readLine());
- StringTokenizer s2 = new StringTokenizer(f.readLine());
- // Get line, break into tokens
- String str1 = s1.nextToken();
- String str2 = s2.nextToken();
- char[] myArray1 = str1.toCharArray();
- char[] myArray2 = str2.toCharArray();
- int length1 = str1.length();
- int length2 = str2.length();
- int[] myArray3 = new int[str1.length()];
- int[] myArray4 = new int[str2.length()];
- for (int i = 0; i<length1; i++){
- myArray3[i] = myArray1[i]-64;
- }
- for (int j = 0; j<length2;j++){
- myArray4[j] = myArray2[j]-64;
- }
- int sum1 = 1;
- int sum2 = 1;
- for (int a = 0; a<length1;a++){
- sum1 *= myArray3[a];
- }
- for (int b= 0; b<length2;b++){
- sum2 *= myArray4[b];
- }
- if ((sum1%47)==(sum2%47)){
- out.println("GO");
- } else{
- out.println("STAY");
- }
- out.close(); // close the output file
- System.exit(0); // don't omit this!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment