Majzer

Game of Stones - Java

Sep 30th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.io.*;
  2. import java.math.*;
  3. import java.security.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import java.util.concurrent.*;
  7. import java.util.regex.*;
  8.  
  9. public class Solution {
  10.  
  11.     // Complete the gameOfStones function below.
  12.     static String gameOfStones(int n) {
  13.         return n % 7 == 0 || n % 7 == 1 ? "Second" : "First";
  14.     }
  15.  
  16.     private static final Scanner scanner = new Scanner(System.in);
  17.  
  18.     public static void main(String[] args) throws IOException {
  19.         BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
  20.  
  21.         int t = scanner.nextInt();
  22.         scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
  23.  
  24.         for (int tItr = 0; tItr < t; tItr++) {
  25.             int n = scanner.nextInt();
  26.             scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
  27.  
  28.             String result = gameOfStones(n);
  29.  
  30.             bufferedWriter.write(result);
  31.             bufferedWriter.newLine();
  32.         }
  33.  
  34.         bufferedWriter.close();
  35.  
  36.         scanner.close();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment