uva 10916 Factstone Benchmark(对数函数的活用)
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
题目大意:给出年份,每个10年对应一个当前计算机可支持的字节位数,计算n! < max(max 为当前计算机能表示的最大整数),求最大n.
#include<stdio.h>
#include<math.h> int main(){
int year;
while (scanf("%d", &year), year){
int n = (year - 1940) / 10;
double k = pow ( 2, n) * log10(2), sum = 0;
for (int i = 1; ; i++){
sum += log10(i);
if (sum > k){
printf("%d\n", i - 1);
break;
}
}
}
return 0;}
uva 10916 Factstone Benchmark(对数函数的活用)的更多相关文章
- HDU     1141    Factstone Benchmark    (数学 )
		
题目链接 Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a ...
 - Factstone Benchmark
		
[问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了6 ...
 - poj 2661 Factstone Benchmark (Stirling数)
		
//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1. log2(n!) = log2(1) + lo ...
 - sicily 1119 Factstone Benchmark
		
题意:求满足n! < 2^k,n的最大值! 解题:指数比较转换成对数比较,达到降幂! 其中: log (n!) = log(n)+log(n-1)+...+log(1); log(2^k) = ...
 - poj 2661  Factstone Benchmark
		
/** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...
 - poj2661 Factstone Benchmark(大数不等式同取对数)
		
这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log ...
 - Factstone Benchmark(数学)
		
http://poj.org/problem?id=2661 题意:Amtel在1960年发行了4位计算机,并实行每十年位数翻一番的策略,将最大整数n作为改变的等级,其中n!表示计算机的无符号整数(n ...
 - 【poj2661】Factstone Benchmark(斯特林公式)
		
传送门 题意: 给出\(x,x\leq 12\),求最大的\(n\),满足\(n!\leq 2^{2^x}\). 思路: 通过斯特林公式: \[ n!\approx \sqrt{2\pi n}\cdo ...
 - UVA题目分类
		
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
 
随机推荐
- 基于管道通知的百万并发长连接server模型
			
0.前言 最近突然想了解怎样设计一个支持百万连接的后台server架构. 要设计一个支持百万连接的后台server,我们首先要知道会有哪些因素限制后台server的高并发连接,这里想到的因素有以下几点 ...
 - js调用.net后台事件,和后台调用前台等方法以及js调用服务器控件的方法
			
http://blog.csdn.net/deepwishly/article/details/6670942 ajaxPro.dll基础教程(前台调用后台方法,后台调用前台方法) 1. javaS ...
 - Git新手入门手册
			
1.配置email及name git config --global user.email "guxuelong@f-road.com.cn" git config --globa ...
 - FreeRTOS随记
			
任务函数原型: void ATaskFunction(void * pvParameters); 任务不允许从实现函数中返回.如果一个任务不再需要,可以用vTaskDelete()删除; 一个任务函数 ...
 - python读取excel文件
			
一.xlrd的说明 xlrd是专门用来在python中读取excel文档的模块,使用前需要安装. 可以到这https://pypi.python.org/pypi/xlrd进行下载tar.gz文件,然 ...
 - linux源码Makefile的详细分析
			
目录 一.概述 1.本文的意义 2.Linux内核Makefile文件组成 二.Linux内核Makefile的“make解析”过程 1 顶层Makefile阶段 1.从总目标uImage说起 2.v ...
 - C#反射(一)  【转】
			
在还不太熟悉反射的昨天,以为反射很神秘,在网上到处找答案.今天找了段代码敲了一下,茅塞顿开!其实反射也就那么简单的一回事! 反射是一种机制,通过这种机制我们可以知道一个未知类型的类型信息.比如, ...
 - Myeclipse中可以正常显示,但运行后的网页找不到图片
			
目录为: 1 douban 1.1 css 1.2 image 2 pages 2.1 index.jsp 路径为:<img src="../douya/image/lg ...
 - 解除網頁無法選取文字、鎖右鍵限制:Enable Copy(Chrome 擴充套件)
			
有些网页因会因为某些因素而禁止浏览者直接复制网页上的内容,虽然我们了解站方的意思,不过有些时候会造成一些不必要的困扰. Enable Copy 这款Chrome 扩充套件可以帮你一键解除封锁右键和选取 ...
 - bzoj2733
			
好久没写treap,稍微练练treap的启发式合并 ; ..,..] of longint; root,a,b,fa,count,f:..] of longint; j,n,m,k,x,y,i:lon ...