m! <= 2^n ,求最大的m;
两边同时取对数。
1 #include<iostream> 2 #include<cmath> 3 4 using namespace std; 5 6 int f[21]; 7 8 int main() 9 { 10 int n, i, j, k; 11 double sum=0; 12 for (i=0, j=0, k=4; i<21; i++, k*=2) 13 { 14 for (j++; ; j++) 15 { 16 sum+=log10((double)j); 17 if (sum >= k*log10(2.)) 18 { 19 f[i]=j-1; 20 break; 21 } 22 } 23 } 24 while(cin >> n, n) 25 cout << f[(n-1960)/10] << endl; 26 return 0; 27 }