博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Uva 10916 - Factstone Benchmark
阅读量:7059 次
发布时间:2019-06-28

本文共 1674 字,大约阅读时间需要 5 分钟。

 

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 Factstonerating 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
#include
#include
#define BASE 1960int main(){ int y, i, n; double times, sum; while(scanf("%d", &y) != EOF && y != 0) { for(i=1; (i-1)*10+BASE<=y; ++i); n = (int)pow((double)2, (double)i); times = 1.0*n*log10((double)2); for(sum=0, i=1; ; i++) { sum += log10((double)i); if(sum > times) break; } printf("%d\n", --i); } return 0;}

解题思路:

题目的意思是想让你根据题目的背景,通过计算出给定的年代里那是计算机内存里可以表示多少位数(二进制),然后得到能够存储进去的最大的十进制数得到能小于或者等于这个数的n的阶乘的n

差点让我用上大数的方法了,转换成另外一种思路同样也是可以达到目的了,学习了

转载于:https://www.cnblogs.com/liaoguifa/archive/2013/03/06/2946592.html

你可能感兴趣的文章
Jetty的配置
查看>>
scala函数等号省略
查看>>
通过AutoConfig实现Form Server配置文件的修改 【转载】
查看>>
20165324 2017-2018-2 《Java程序设计》课程总结
查看>>
8-unittest中case管理
查看>>
ExtJs XTemplate
查看>>
[转载[工具]]PLSQL使用技巧
查看>>
用户管理的设计--1.首页查询功能实现
查看>>
PHP保留两位小数
查看>>
numpy 数组相减
查看>>
getRequestDispatcher(path).forward(),,执行完,后面的代码居然还会执行!!!记得加return 啊亲...
查看>>
如何安装和配置RabbitMQ
查看>>
08-jQuery的位置信息
查看>>
MFC树控件CTreeCtrl
查看>>
007——数组(七)通过回调函数得到数组交集或差集
查看>>
php中的curl的一些参数总结
查看>>
Objective-c——多线程开发第一天(pthread/NSThread)
查看>>
Linux下网站压力测试最简单好用的软件,零基础也可以搭建和使用!
查看>>
Search in Rotated Sorted Array
查看>>
box-sizing 盒模型
查看>>