Document directory
- Sample Input
- Output for sample input
Problem B: factstone Benchmark
Amtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, continuing its strategy of doubling the word-size every ten years. (amtel released a 64-bit computer in 2000, a 32-bit computer in 1990, a 16-bit
Computer in 1980, an 8-bit computer in 1970, and a 4-bit computer, its first, in 1960 .)
Amtel will use a new benchmark-Factstone-To advertise the vastly improved capacity of its new chips.
FactstoneRating is defined to be the largest integerNSuch that
N!Can be represented as an unsigned integer in a computer word.
Given a year1960 ≤ y ≤ 2160, What will beFactstoneRating of amtel's most recently released chip?
There are several test cases. For each test case, there is one line of input containing
Y. A line containing 0 follows the last test case. For each test case, output a line giving the factstone rating.
Sample Input
196019810
Output for sample input
38
Calculate the maximum value of N, 2 ^ n> N !, I have previously done some silly questions and I forget n! It is very difficult to cross-border, and the logarithm can be used to solve the problem.
LG (2 ^ N)> LG (N !)
N * lg2> lg1 + ...... lgn
# Include <stdio. h>
# Include <math. h>
Void main ()
{Int N, I;
Double M, S;
While (scanf ("% d", & N), n)
{M = POW (2, (n-1940)/10) * log (2 );
S = 0;
For (I = 1; S <m; I ++)
S + = Log (I );
Printf ("% d \ n", I-2 );
}
}