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. tinker接入

    对于热修复无非就是两大类,一类是tencent代表的classloader模式的,另一类是阿里系代表的底层方面替换. 下面以本人的经验介绍下微信的tinker接入: 命令行接入方式: gradle接入 ...

  2. win10 关闭 “在时间线中查看更多日期” 提示

    在组策略中,禁用允许上传用户活动

  3. Redis系列---安装redis单机版02

    本章将带领大家一步一步安装Redis单机版(Redis从3.0版本后就开始支持集群了,集群将会后边章节带领大家操作) 准备环境: Centos 6.X redis3.+版本(自行下载,redis 的版 ...

  4. ASP.NET MVC AJAX 请求中加入 antiforgerytoken 解决“所需的防伪表单字段“__RequestVerificationToken”不存在”问题

    在ASP.NET mvc中如果在表中使用了@Html.AntiForgeryToken(),ajax post不会请求成功 解决方法是在ajax中加入__RequestVerificationToke ...

  5. 解决webservice(Java)中dao层注入为null问题

    首先在webservice指定发布的路径类中实现 ServletContextListener, 例如: import javax.servlet.ServletContextEvent; impor ...

  6. CPU与GPU基础知识与品牌

    1 CPU信息 ubuntu系统: lscpu 序号 属性 描述 1 架构 x86_64 2 CPU 运行模式 32-bit, 64-bit 3 字节序 Little Endian 4 CPU内核数量 ...

  7. 【bzoj1941】[Sdoi2010]Hide and Seek(kd-tree)

    bzoj 题意: 给出\(n\)个点,对于每个点,\(d_i\)等于距离其最远的点的距离减去距离最近的点的距离.这里的距离为曼哈顿距离. 求\(min\{d_i\}\). 思路: 考虑直接对每个点暴力 ...

  8. jmeter beanshell断言接口自动化实例

    一.JMeter介绍 Apache JMeter是一款优秀的开源性能测试工具,在国外无论是在性能测试还是接口测试领域都有着非常高的使用率,但由于本身没有完善的中文文档以及典型开源工具特点(界面不美观) ...

  9. c# 第32节 类的继承

    本节内容: 1:为什么要继承 2:继承特点 3:继承的实现 4:子类传统构造,与base构造 1:为什么要继承 2:继承特点 什么是继承: 继承就是子类包含父类的数据结构和行为方式, 包括字段.属性. ...

  10. Vue+cordova开发App

    Vue+cordova开发App https://www.imooc.com/article/70062