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. Random random = new Random();
  13.  
  14. for (int rep = 0; rep < 10; ++rep) {
  15. int[] n = new int[4];
  16. int sum = 0;
  17. for (int i = 0; i < 4; ++i) {
  18. sum += (n[i] = random.nextInt());
  19. }
  20.  
  21. int r = sum % 4;
  22. if (random.nextInt(2) < 1) {
  23. n[random.nextInt(4)] -= r;
  24. } else {
  25. n[random.nextInt(4)] += 4 - r;
  26. }
  27.  
  28. sum = 0;
  29. for (int i = 0; i < 4; ++i) {
  30. sum += n[i];
  31. }
  32. System.out.println(Arrays.toString(n) + " " + sum + " " + (sum % 4));
  33. }
  34. }
  35. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
[1799732408, -455707592, 1098235207, 1961963885] 109256612 0
[-222620907, 1929045918, 1284608772, -2101487967] 889545816 0
[-195083765, 338953151, -528615039, 951737077] 566991424 0
[-251802544, 1648034020, -90143473, 2017925381] -970953912 0
[-2092251378, -975013920, -1737696931, -2033832515] 1751139848 0
[90301676, 1905895349, 996310629, -1819341674] 1173165980 0
[1609118673, 1361591639, -1567977322, 2080717302] -811517004 0
[-1827561620, 606147639, 1123703511, 139640970] 41930500 0
[-1956545885, -1010667149, -925355163, -1649143027] -1246743928 0
[977272947, -1022104403, -2020610879, -994492625] 1235032336 0