fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner sc = new Scanner(System.in);
  14. System.out.println(canWinNim(sc.nextInt()));
  15.  
  16. }
  17. static boolean canWinNim(int n) {
  18. boolean a = true;
  19. while(n>0){
  20. if(a){
  21. n-=3;
  22. a=false;
  23. }
  24. else {
  25. n-=1;
  26. a=true;
  27. }
  28. }
  29. if(a) return false;
  30. return true;
  31.  
  32. }
  33. }
Success #stdin #stdout 0.14s 54500KB
stdin
150
stdout
true