fork(1) download
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class StoneDivision {
  5.  
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8.  
  9. long n = scan.nextLong();
  10. int m = scan.nextInt();
  11. long si[] = new long[m];
  12.  
  13. for (int i = 0; i < m; i++) {
  14. si[i] = scan.nextLong();
  15. }
  16.  
  17. Arrays.sort(si);
  18.  
  19. if (calculateWin(n, m, si, si.length - 1, 1)) {
  20. System.out.println("First");
  21. } else {
  22. System.out.println("Second");
  23. }
  24. }
  25.  
  26. static boolean calculateWin(long n, int m, long[] si, int siIndex, int count) {
  27.  
  28. long siN = si[siIndex];
  29.  
  30. if (n / siN == 0)
  31. return true;
  32.  
  33. if (n == 1)
  34.  
  35. if (n % siN == 0) {
  36. long nN = n / siN;
  37. count++;
  38. }
  39.  
  40. return calculateWin(n, m, si, siIndex - 1, count);
  41.  
  42. }
  43.  
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class StoneDivision is public, should be declared in a file named StoneDivision.java
public class StoneDivision {
       ^
1 error
stdout
Standard output is empty