Sicily 1119. Factstone Benchmark

1119. Factstone Benchmark

 
     
     
 

Time Limit: 1sec    Memory Limit:32MB

Description

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.

Input

Given a year 1960 ≤ y ≤ 2160, what will be the Factstone rating of Amtel‘s most recently released chip?

Output

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

 Copy sample input to clipboard

1960
1981
0

Sample Output

3
8
 
     
     
 

Status

Submit

Source Code

// Problem#: 1119
// Submission#: 3731244
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
int main(){
    int year;
    int endflag;
    int n;
    double sum;
    while(scanf("%d", &year) && year){
        endflag = pow(2, (year - 1960) / 10 + 2);
        n = 2;
        sum = 0;
        while(sum <= endflag){
            sum += log(n) / log(2);
            ++n;
        }
        printf("%d\n", n - 2);
    }
    return 0;
}                                 
时间: 2024-10-16 22:39:21

Sicily 1119. Factstone Benchmark的相关文章

SOJ 1119. Factstone Benchmark

题目大意: 给定y,求满足22((y-1960)/10+2) > k!的k的最大值. 解题思路:通过两边同时去对数,达到降幂的效果,使得两边的数能用自带类型存储.取对数后:2((y-1960)/10+2)  * log(2)> log(k!). 进一步转化:2((y-1960)/10+2) > log(k!) / log(2) = log(k) / log(2) + log(k-1)/log(2) + log(k-2) / log(2) + ... +log(1)/log(2). 由于y

hdu 1141 Factstone Benchmark 数论水题,,阶乘用斯特林公式

Factstone Benchmark Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1760    Accepted Submission(s): 973 Problem Description Amtel has announced that it will release a 128-bit computer chip by

Factstone Benchmark

[问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了64位计算机,在1990年发行了32位计算机,在1980年发行了16位计算机,在1970年发行了8位计算机,并首先在1960年发行了4位计算机) Amtel将使用新的标准检查等级——Factstone——来宣传其新芯片大大提高的能力. Factstone等级被定义为这样的最大整数n,使得n!可以表示为

poj2661 Factstone Benchmark(大数不等式同取对数ji)

这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log2(2k-1)<k 其中k是第y年计算机的位数. 注意C++中log(n)是以e为底的对数,log10(n)是以10为底的对数,若要计算loga(b),用换底公式loga(b)=logx(b)/logx(a)即可. #include<iostream> #include<cstdio&

编程题目分类(剪辑)

1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. 模拟 12. 算术与代数 13. 组合问题 14. 数论 15. 网格,几何,计算几何 [编程入门] PC 110101, uva 100, The 3n+1 problem, 难度 1 PC 110102, uva 10189, Minesweeper, 难度 1 PC 110103, uva 10137, The T

(转)sicily题目分类

Sicily题目分类 ·         [数据结构/图论] 1310 Right-Heavy Tree   笛卡尔树相关,复杂度O(N)或O(NlogN). ·1426 Phone List         电话号码前缀检索,trie树相关. ·1443 Printer Queue      基本队列操作. ·1149 等价表达式         判断表达式是否等价(递归求解) ·1136 山海经             n长序列里求m次区间询问的最大连续子区间和.线段树/RMQ ·1252

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116