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 - the Factstone - to advertise the vastly improved capacity of its new chips. The Factstone rating is defined to be the largest integer n such that n! can be represented as an unsigned integer in a computer word.
Given a year 1960 ≤ y ≤ 2160, what will be the Factstone rating 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
1960 1981 0
Output for Sample Input
3 8
题意:来自http://www.nocow.cn/index.php/UVA/10916
Amtel公司宣布他们会在2010年发行128位元的计算机,
在2020年发行256位元的计算机,
在这个策略之下往后每10年就发行2倍位元的计算机。
(Amtel公司在2000年发行 64位元,1990年发行32位元计算机,
1980年发行16位元计算机,1970年发行8位元计算机,
1960年发行4位元计算机,也是第一部计算机)。
Amtel公司将使用一种新的规格基准 「Factstone」来广告并凸显新一代计算机芯片容量的神速进步。
「Factstone」的等级被定义为:
以一个最大的整数 n 表示,使得 n! 可以在一个计算机字组(word,也就是我们说的多少位元)中
被以 unsigned integer(无号整数)来表示。
例如:在1960年时的计算机为4位元,也就是一个字组能表达 0~15的整数。
而 3! 是在这个范围中最大的阶层数了(4! > 15),所以其「Factstone」等级是 3。
给你一个公元年数 y ,请问最新发行的Amtel计算机其「Factstone」等级是多少?
[编辑] Input
輸入包含多組測試資料,每組測試資料一列,含有一個整數 y。(1960 <= y <= 2160)
當 y=0 時代表輸入結束。
[编辑] Output
對每一組測試資料輸出一列。輸出在 y 年時最新發行的Amtel電腦其「Factstone」等級是多少。
关键语句
Given a year 1960 ≤ y ≤ 2160, what will be the Factstone rating of Amtel's most recently released chip?
说白了就是求出最大m使得m! <= 2^n,。。。
两边同时取对数有(log1 + log2 + log 3 + .... + log4+..) <= n,对前面的求和比较找出m就可以了
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
}