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 ...
随机推荐
- Linux系统工程师学习方法
学习顺序: 一.至少熟悉一种嵌入式芯片架构 最适合初学者的就是arm芯片 二.uboot的使用与移植 首先要了解uboot的启动流程,根据启动顺序,进行代码的修改.编译与移植 三.linux驱动开发 ...
- iOS: 学习笔记, 用代码驱动自动布局实例
iOS自动布局是设置iOS界面的利器. 本实例展示了如何使用自动布局语言设置水平布局, 垂直布局 1. 创建空白iOS项目 2. 添加一个控制器类, 修改YYAppDelegate.m文件 #impo ...
- POJ 3041 Asteroids 最小点覆盖 == 二分图的最大匹配
Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape o ...
- SignalR介绍与Asp.net,前台即时通信【转】
SignalR 是一个asp.net异步库,它提供广播消息到多个client端的机制. SignalR能用来持久客户端与服务端的连接,让我们便于开发一些实时的应用,例如聊天室在线预订系统,股票交易等实 ...
- iOS:实现表格填充和选择操作
功能:创建一个列表,用数组填充表格,并支持选择列表行 // // main.m // Hello // // Created by lishujun on 14-8-28. // Copyright ...
- linux tcp 好文
http://blog.csdn.net/htttw/article/details/7521053
- bzoj 3594: [Scoi2014]方伯伯的玉米田 dp树状数组优化
3594: [Scoi2014]方伯伯的玉米田 Time Limit: 60 Sec Memory Limit: 128 MBSubmit: 314 Solved: 132[Submit][Sta ...
- bzoj 1031: [JSOI2007]字符加密Cipher 後綴數組模板題
1031: [JSOI2007]字符加密Cipher Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3157 Solved: 1233[Submit ...
- [BZOJ 3680] 吊打XXX 【模拟退火】
题目链接:BZOJ - 3680 题目分析 这道题是SLYZ的神犇把JSOI的平衡点那道题改了一下题面变成了吊打GTY神犇..Orz 第一次写模拟退火,只能照着别人的代码写,我看的是PoPoQQQ神犇 ...
- leetcode面试准备: Jump Game
1 题目 Given an array of non-negative integers, you are initially positioned at the first index of the ...