import java.math.BigInteger; import java.util.Random; class zz { // BigInteger one = BigInteger.ONE; static BigInteger one = BigInteger.valueOf(1); static BigInteger radix = one.shiftLeft(30); static BigInteger msk = radix.subtract(one); static String[] cmds = {"big", "prime", "time"}; private static String ms(BigInteger z){if(z.signum() > 0) return ", 0x" + z.and(msk).toString(16) + ms(z.shiftRight(30)); else return "";} private static String cs(char c, int t, BigInteger m) {return "int "+c+"["+t+"] = {" /*}*/ + ms(m).substring(2) + /*{*/ "};\n";} public static void main(String[] args) {flutz: { int c=-1; {int j = cmds.length; while(j-- > 0) if(args[0].equals(cmds[j])) c = j;} if(c==-1) break flutz; int s = Integer.parseInt(args[1]); BigInteger m = (c==1)?(new BigInteger(s, 12, new Random(42))) :(new BigInteger(s, new Random(s))).setBit(s-1); BigInteger e = (c==1)? m.subtract(BigInteger.valueOf(1)) :new BigInteger(s-1, new Random(s)); BigInteger b = new BigInteger(s-1, new Random(59)); if(c<2) {int t = (s+119)/120*4; System.out.println("#define Ss " + t/4 + "\n" + cs('m', t, m) + cs('e', t, e) + cs('b', t, b) + cs('a', t, b.modPow(e, m)));} else for(int q = 0; q < 20; ++q) System.out.println("num^e & 15 = " + b.modPow(e, m).and(BigInteger.valueOf(15))); }} }