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 ...
随机推荐
- umask默认权限分配
umask默认权限分配的命令 当我们登录系统之后创建一个文件总是有一个默认权限的,那么这个权限是怎么来的呢?这就是umask干的事情.umask设置了用户创建文件的默认 权限,它与chmod的效果刚好 ...
- jQuery 标签淡入淡出 个人随笔
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 通过javascript实现页面的横竖屏固定
javascript是不能固定页面是横屏还是竖屏的,但是我们可以通过另外一种思路来监听window.orientation状态,假设我们要固定页面为横屏显示,则当window.orientation返 ...
- 关闭linux终端命令行退格报警声(centos7亲测有效)
首先这个声音不是外置音频设备发出,而是主板上的蜂鸣器 1,使用root账户登录 2,vi 打开 ~/.bashrc 脚本 3,在脚本的最后一行加上 setterm -blength 0 4,保存脚本 ...
- UML for Design Pattern
************************************************************************************* ************** ...
- Python: 设计模式 之 工厂模式例(2)(神奇的Python)
#!/usr/bin/env python #coding=utf-8 # # 工厂模式第二例(神奇的Python) # 版权所有 2014 yao_yu (http://blog.csdn.net/ ...
- 当xcode里点运行出现treating unicode character as whites
可能是由于粘贴网页上的代码的时候两行之间的回车引起的,两行之间重新输入回车就行......删掉重新写一遍就ok了 引入网页上的回车时 可能 网页对其格式做了处理,所以Xcode 不认识了
- 完美方案——iOS的WebView自适应内容高度
/////////////////////////////初始化,self.view是父控件///////////////////////////////// _webView = [[UIWebVi ...
- StartSSL免费SSL证书成功申请-HTTPS让访问网站更安全
StartSSL免费SSL证书成功申请-HTTPS让访问网站更安全 一.StartSSL个人证书登录申请 1.StartSSL官网: 1.官方首页:http://www.startssl.com/ 2 ...
- 修炼debug
常用方法: alert console.log 行号手工打breakpoints 手工加入debugger:配合条件if(){debugger;} break on dom modify eventL ...