简单的大数乘法,直接改16进制~~
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#define maxn 3010
#define INF 0x7fffffff
#define ull unsigned long long
using namespace std;
int f[maxn], ans[110];
void init()
{memset(f, 0, sizeof(f));memset(ans, 0, sizeof(ans));f[0] = 1;for(int i = 2; i <= 100; ++ i){int x = 0;for(int j = 0; j < maxn; j++){int s = f[j] * i + x;f[j] = s%16;x = s/16;}int k;for(k = maxn-1; k >= 0; k--) if(f[k]) break;for(int j = 0; j <= k; j++) if(!f[j]) ans[i]++;}
}
int main()
{init();int n;while(scanf("%d", &n) == 1){if(n < 0) break;printf("%d\n", ans[n]);}return 0;
}