#include #include #include #include #include using namespace std; int *val = 0; int up = 1000000; int &Q(int n) { if (n<1 || n>up) { throw "out of bounds"; } else { return val[n-1]; } } vector i; int w = 0; int mx = 10; void complete(int n0) { try { for (int n=n0; n<=up; n++) { int val = 0; for (size_t k=0; k1) { printf(", "); } try { int val = 0; for (size_t k=0; k0; } else { return false; } } int main(int argc, const char **argv) { if (argc==1) { printf("Usage: %s options...\n" "Options are:\n" " up=# compute/check up to this number of terms (at least 1000)\n" " w=# fixed number of random initial values\n" " when missing: explore all solutions with 1, 2, 3, ... initial values\n" " max=# max value for initial terms\n" " # offsets to satisfy: Q(n) = Sum Q(n-Q(n-#))\n", argv[0]); } else { for (int a=1; a100) { printf("w way too large\n"); return 2; } if (i.size()==0) { printf("missing offsets\n"); return 3; } val = (int*)malloc(up * sizeof(int)); if (val==0) { printf("out of memory\n"); return 4; } search(); free(val); val = 0; } return 0; }