Factstone Benchmark
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5577   Accepted: 2524

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.

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

Input

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.

Output

For each test case, output a line giving the Factstone rating.

Sample Input

1960
1981
0

Sample Output

3
8

Source

OJ-ID:
poj-2661

author:
Caution_X

date of submission:
20191010

tags:
math

description modelling:
给定一个数x(x可以达到256位),找到一个数n满足n!<=x&&(n+1)!>x

major steps to solve it:
1.因为x可以达到256位,所以我们同时对n!<=x和(n+1)!>x去对数
2.得到log(n)+log(n-1)+.......+log(1)<=log(x)&&log(n+1)+log(n)+......+log(1)>log(x)

AC Code:

#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n;
double w;
while(~scanf("%d",&n)&&n) {
w=log();
for(int i=;i<=n;i+=) {
w*=;
}
int i=;
double f=;
while(f<w) {
f+=log((double)++i);
}
printf("%d\n",i-);
}
}

POJ-2661Factstone Benchmark的更多相关文章

  1. POJ 2661Factstone Benchmark(斯特林公式)

    链接:传送门 题意:一个人自命不凡,他从1960年开始每10年更新一次计算机的最长储存长数.1960年为4位,每10年翻一倍.给出一个年份y,问这一年计算机可以执行的n!而不溢出的最大n值 思路:如果 ...

  2. poj 2661 Factstone Benchmark (Stirling数)

    //题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1.   log2(n!) = log2(1) + lo ...

  3. poj 2661 Factstone Benchmark

    /** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...

  4. poj 1502 最短路+坑爹题意

    链接:http://poj.org/problem?id=1502 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  5. POJ 1502 MPI Maelstrom(最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4017   Accepted: 2412 Des ...

  6. (poj)1502 MPI Maelstrom

    题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor A ...

  7. POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom /ZOJ 1291 MPI Maelstrom (最短路径)

    POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom ...

  8. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  9. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  10. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

随机推荐

  1. UTF-8和BOM的一些说明

    BOM的含义 BOM即Byte Order Mark字节序标记.BOM是为UTF-16和UTF-32准备的,用户标记字节序(byte order).拿UTF-16来举例,其是以两个字节为编码单元,在解 ...

  2. eclipse彻底去除validation(彻底解决编辑js文件的卡顿问题)

    Eclipse中默认的JS编辑器非常慢,尤其在拷贝粘贴代码时,CPU总是占用很高甚至到100%,也就导致了编辑起来很卡. 这是因为Eclipse中带的Validate功能导致的,这个鸡肋的功能简直让人 ...

  3. C++ getline函数用法详解

    转载自http://c.biancheng.net/view/1345.html 虽然可以使用 cin 和 >> 运算符来输入字符串,但它可能会导致一些需要注意的问题. 当 cin 读取数 ...

  4. 教你如何用Python向手机发送通知

    ------------恢复内容开始------------ 你曾想尝试在服务器端或电脑上向手机发送通知吗? 你曾烦恼过企业邮箱的防骚扰机制吗? 现在,我们可以用一种简单轻松的方法来代替企业邮箱了! ...

  5. python3 对list对象的增删改查

    class peoples: people_list =[] class people: name='' age=-1 def __init__(self,name,age): self.name = ...

  6. JAVA 基础篇

    一.数组 1. 什么是数组? 数组和变量差不多,也是可以存放数据的,但是数组可以存放多个数据,而且多个数据的数据类型统一 格式 数据类型 [] 数组名称; 还有一种等效的写法,不推荐 数据类型 数组名 ...

  7. python 通过使用pandas的实现的Excel的批量转换CSV文件的处理

    ---恢复内容开始--- 最近同事在处理文件导入的时候需要把一批文件换成CSV的格式,但是直觉修改后缀是不生效的,而且xlsx和xls的文件没法直接换成CVS的文件,所以找了一下方式,并且自己实现了p ...

  8. ES6复制拷贝数组,对象,json数组

    扩展运算符的应用spread打散数组[...] (1)复制数组 数组是复合的数据类型,直接复制的话,只是复制了指向底层数据结构的指针,而不是克隆一个全新的数组. const a1 = [1, 2]; ...

  9. Apache2 在Linux环境下的安装

    安装Apache2: apt-get install apache2 启动Apache2服务: service apache2 start 在终端运行启动后,打开浏览器URL访问 http://loc ...

  10. SILK编码语音转WAV格式

    - SILK编码 SILK采样率可为8.12.16或24 kHz,比特率可为6至40 kbit/s.对应到报文层面的直观印象,即SILK编码的语音数据每帧长度是不等的. SILK编码已经开源,目前可下 ...