[Java] Your Ride Is Here

/* Use the slash-star style comments or the system won't see your
   identification information */
/*
ID: lincans1
LANG: JAVA
TASK: ride
*/
import java.io.*;
import java.util.Scanner;

class ride {
    
    
  public static int count(String str) {
    
    
		int num = 1;
	    for (char ch : str.toCharArray()) {
    
    
	    	num *= (ch - 'A' + 1);
	    }
	    return num;
	}

	public static void main(String[] args) throws IOException, Exception {
    
    
	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ride.out")));
	    Scanner in = new Scanner(new File("ride.in"));
	    
	    String comet = in.next(), team = in.next();
	    int comet_num = count(comet);
	    int team_num  = count(team);
	    if (comet_num % 47 == team_num % 47) {
    
    
	    	out.println("GO");
	    }
	    else {
    
    
	    	out.println("STAY");
	    }
	    in.close();
	    out.close();
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_41714373/article/details/111716655