10916 - Factstone Benchmark
来源:互联网 发布:明初的疆域 知乎 编辑:程序博客网 时间:2024/05/04 10:22
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 integern 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
196019810
Output for Sample Input
38
Charles L. A. Clarke and Gordon V. Cormack
这道题大致就是求出最大的n,条件是n!在2^N的氛围内。告诉你N。
这道题肯定是会超出int类型的。不过N的值是确定的十几二十个吧,所以可以一开始的时候用打表的方式打出所有的值。
这里打表是有技巧的,每次乘2之后,都要看看能不能再除以n+1,这样数据范围始终不会超了
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<ctype.h>#include<algorithm>#include<queue>#include<stack>using namespace std;int a[25]={0};int n,t=0;double shang;int go(int x){ int i; for (i=x+1; i<=2*x; i++) { shang*=2; if (shang/(n+1)>=1) { shang/=(n+1); n=n+1; } } a[t]=n; t++; if (t>22) return 0; go(2*x);}int main (){ int y,i; shang=4*1.0/6.0; n=3; go(2); while(cin>>y) { if (y==0) break; cout<<a[(y-1960)/10]<<endl; } return 0;}
- UVa 10916 Factstone Benchmark
- uva 10916 Factstone Benchmark
- UVA 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- uva 10916 - Factstone Benchmark
- uva-10916 - Factstone Benchmark
- 10916 - Factstone Benchmark
- Uva 10916 - Factstone Benchmark
- uva 10916 - Factstone Benchmark
- 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- 10916 - Factstone Benchmark
- UVA 10916 Factstone Benchmark
- uva 10916 Factstone Benchmark
- UVa 10916 Factstone Benchmark
- 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- String to Integer (atoi)
- iOS和java之间的RSA加密解密、加签认证对接
- ExtJS梦想之旅(八)--GridPanel和EditorGridPanel的使用
- 能力工场--关于在JavaScript中使用EL表达式的问题
- 接口,抽象类
- 10916 - Factstone Benchmark
- Linux下启动oracle数据库
- JAVA 线程总结
- 三大WEB服务器对比分析 (apache ,lighttpd,nginx)
- 持续集成之路——服务层的单元测试
- hdu 1828 Picture(线段树扫描线矩形周长并)
- 【笔面大全】螺旋矩阵问题汇总
- JavaScript--在页面的下拉框控件中遍历出日期--能力工场
- 自画窗口专题