Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- long long dp[(1 << 20)];
- long long
- solve()
- {
- long long res = 0LL;
- dp[0] = 0LL;
- for (int c = 0; c < (1 << 20); ++c)
- dp[c] = 1LL;
- for (int n = 1; n < 18; ++n)
- for (int c = (1 << 20) - 1; c >= 0; --c) {
- dp[c] = 0LL;
- for (int d = 0; d < 10; ++d)
- if (((c >> (d << 1)) & 3) > 0)
- dp[c] += dp[(c & (~(3 << (d << 1)))) | ((((c >> (d << 1)) & 3) - 1) << (d << 1))];
- }
- for (int d = 1; d < 10; ++d)
- res += dp[(((1 << 20) - 1) & ((~(3 << (d << 1))))) | (2 << (d << 1))];
- return (res);
- }
- int
- main()
- {
- printf("Euler #172 : %lld\n", solve());
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement