Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Main {
- public static boolean Game1(long n, long m){
- return n % (m + 1) != 0;
- }
- public static boolean Game2(long n, long m, String Player1, String Player2) {
- if(m == 1) {
- return n%2 == 1;
- }
- if(Player1.equals("Alice")) {
- return n != (m + 1);
- } else {
- return (n <= m) || (n == (2*m + 1));
- }
- }
- public static boolean Game3(long n, long m) {
- return Math.ceil(n * 1.0 / m) % 2 == 1;
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int Q = sc.nextInt();
- for(int i=1; i<=Q; i++) {
- long n = sc.nextLong();
- long m = sc.nextLong();
- String Player1 = sc.next();
- String Player2 = Player1.equals("Alice") ? "Bob" : "Alice";
- System.out.println("Test-Case #" + i + ":");
- System.out.println("G1: " + (Game1(n, m) ? Player1 : Player2));
- System.out.println("G2: " + (Game2(n, m, Player1, Player2) ? Player1 : Player2));
- System.out.println("G3: " + (Game3(n, m) ? Player1 : Player2));
- System.out.println();
- }
- sc.close();
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment