@@ -0,0 +1,1028 @@
+import java.math.BigInteger;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A@SuppressWarnings(%22unused%22)%0Apublic class P078 implements Puzzle %7B%0A    @Override%0A    public String solve() %7B%0A%0A        final BigInteger MILLION = BigInteger.valueOf(1000000);%0A%0A        Map%3CLong, BigInteger%3E r = new HashMap%3C%3E();%0A        r.put(0L, BigInteger.ONE);%0A%0A        for (long i = 1; ; i++) %7B%0A            final BigInteger result = p(r, i);%0A            if (result.mod(MILLION).equals(BigInteger.ZERO)) %7B%0A                return %22%22 + i;%0A            %7D%0A%0A            r.put(i, result);%0A        %7D%0A    %7D%0A%0A    private BigInteger p(Map%3CLong, BigInteger%3E results, long n) %7B%0A        if (results.containsKey(n)) %7B%0A            return results.get(n);%0A        %7D%0A%0A        BigInteger s = BigInteger.ZERO;%0A        long k = 2;%0A        for (long j = n - 1; j %3E= 0; ) %7B%0A            BigInteger t = p(results, j);%0A%0A            s = s.add(((k / 2) %25 2 == 1) ? t : t.negate());%0A            j -= (k %25 2 == 1) ? k : k / 2;%0A            k += 1;%0A        %7D%0A        return s;%0A    %7D%0A%7D

add 78