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. long n = 100;
  14. int a[] = new int[n];
  15.  
  16. //XOR of all numbers from 1 to n
  17. // n%4 == 0 ---> n
  18. // n%4 == 1 ---> 1
  19. // n%4 == 2 ---> n + 1
  20. // n%4 == 3 ---> 0
  21.  
  22. long xor = (n % 4 == 0) ? n : (n % 4 == 1) ? 1 : (n % 4 == 2) ? n + 1 : 0;
  23.  
  24. for (long i = 1; i <= n; i++)
  25. {
  26. xor = xor ^ a[i];
  27. }
  28. //Missing number
  29. System.out.println(xor);
  30. }
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:14: error: possible loss of precision
int a[] = new int[n];
                  ^
  required: int
  found:    long
Main.java:26: error: possible loss of precision
    xor = xor ^ a[i];
                  ^
  required: int
  found:    long
2 errors
stdout
Standard output is empty