@@ -0,0 +1,1168 @@
+import java.util.HashMap;%0A%0Apublic class Main %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09// input 5 integers%0A%09%09int a = 1234;%0A%09%09int b = 5678;%0A%09%09int x = 123;%0A%09%09int k = 12345;%0A%09%09int m = 9876;%0A%0A%09%09// int a = 3; int b = 2; int x = 5; int k = 13; int m = 7;%0A%0A%09%09HashMap%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A%0A%09%09// build map table%0A%09%09int order = 1;%0A%0A%09%09while (!map.containsValue(x)) %7B%0A%09%09%09map.put(order, x);%0A%09%09%09// System.out.println(x);%0A%09%09%09x = ((a * x) + b) %25 m;%0A%09%09%09order++;%0A%09%09%7D%0A%0A%09%09int cycle_point = 0;%0A%09%09for (int i = 1; i %3C map.size(); i++) %7B%0A%09%09%09if (map.get(i) == x) %7B%0A%09%09%09%09cycle_point = i;%0A%09%09%09%09// System.out.println(%22is %22 + y);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09if (k %3C map.size()) %7B%0A%0A%09%09%09// print K to K+4%0A%09%09%09int pin = k;%0A%09%09%09for (int i = 0; i %3C= 4; i++) %7B%0A%09%09%09%09System.out.println(map.get(pin));%0A%09%09%09%09pin++;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09else %7B%0A%09%09%09// print K to K+4%0A%09%09%09int pin = (k - (cycle_point - 1))%0A%09%09%09%09%09%25 (map.size() - (cycle_point - 1));%0A%09%09%09if (pin == 0) %7B%0A%09%09%09%09pin = map.size();%0A%09%09%09%7D%0A%09%09%09pin = pin + (cycle_point - 1);%0A%09%09%09for (int i = 0; i %3C= 4; i++) %7B%0A%09%09%09%09if (pin %3E= map.size()) %7B%0A%09%09%09%09%09pin = pin - cycle_point;%0A%09%09%09%09%7D%0A%09%09%09%09System.out.println(pin + %22:%22 + map.get(pin));%0A%09%09%09%09pin++;%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

initialize project