Created
March 3, 2017 14:17
-
-
Save jsn/be53a9debfb10f86a378513b40c16cdd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#ifndef NBITS | |
#define NBITS 42 | |
#endif | |
static unsigned long long states[NBITS + 1][7][2 * NBITS] ; | |
/* step s r */ | |
static inline int next_s(int s, int b) { | |
return (6+s*(5+s*s*s*(2+s*(3+s))) + b*(5+s*(5+s*(6+s*s*(3+s*6))))) % 7 ; | |
} | |
int main(int ac, const char *av[]) { | |
states[0][2][NBITS] = 1 ; | |
for (int i = 0; i < NBITS; i ++) | |
for (int s = 0; s < 7; s ++) | |
for (int r = 1 - NBITS; r < NBITS; r ++) { | |
for (int b = 0; b <= 1; b ++) { | |
int r1 = r ; | |
int s1 = next_s(s, b) ; | |
if (b == s) r1 = r + 2 * b - 1 ; | |
states[i + 1][s1][NBITS + r1] += states[i][s][NBITS + r] ; | |
} | |
} | |
unsigned long long cnt = 0 ; | |
for (int s = 0; s < 7; s ++) | |
for (int r = 1 - NBITS; r < NBITS; r ++) | |
if (r) cnt += states[NBITS][s][NBITS + r] ; | |
printf("%llu\n", cnt) ; | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment