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.  
  11. public static int mod(int a, int b) {
  12. int c = a;
  13. if (a < 0) {
  14. while (a < 0) {
  15. c += b;
  16. }
  17. } else {
  18. c = a % b;
  19. }
  20. return c;
  21. }
  22.  
  23. public static int dom(int a, int b) {
  24. int c = a;
  25. c %= b;
  26. if (c < 0) {
  27. c += b;
  28. }
  29. return c;
  30. }
  31.  
  32. public static void main (String[] args) throws java.lang.Exception
  33. {
  34. int[] arr = {-5, 5, -8, 2, 78, -142, 15375, -1235474, 1423};
  35. for (int i = 0; i < arr.length; i++) {
  36. System.out.println(mod (arr[i], 5) + ", " + dom(arr[i], 5));
  37. }
  38. }
  39.  
  40. }
Time limit exceeded #stdin #stdout 5s 320512KB
stdin
Standard input is empty
stdout
Standard output is empty