求最大的n 满足n! <= 2 ^k
2 ^ k 不会太大,所以可以直接暴力上去.
设2 ^ k 为p
则有:n! <= p ---> log2(n!) <= log2(p) ---> log(n!) <= p ---> log2(1) + log(2) + log(3) .... + log2(n) <= p
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int y;
int main(){while (scanf("%d",&y) && y){int p = 1 << ((y - 1960) / 10 + 2);double sum = 0;int ans = 1;for (;sum <= p; ){sum += log10(ans++) / log10(2);}printf("%d\n",ans - 2);}
}