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. 前端之html5和css3

    圆角,透明度,rgba CSS3圆角 设置某一个角的圆角,比如设置左上角的圆角:border-top-left-radius:30px 60px;同时分别设置四个角: border-radius:30 ...

  2. RocketMQ(4)---RocketMQ核心配置讲解

    RocketMQ核心配置讲解 RocketMQ的核心配置在broker.conf配置文件里,下面我们来分析下它. 一.broker.conf配置 下面只列举一些常用的核心配置讲解. 1.broker. ...

  3. Z从壹开始前后端分离【 .NET Core2.2/3.0 +Vue2.0 】框架之六 || API项目整体搭建 6.1 仓储+服务+抽象接口模式

    本文梯子 本文3.0版本文章 前言 零.完成图中的粉色部分 2019-08-30:关于仓储的相关话题 一.创建实体Model数据层 二.设计仓储接口与其实现类 三.设计服务接口与其实现类 四.创建 C ...

  4. Java 小游戏 - 井字棋 v1.0 (初步完成) (2018.4.16更新)

      井字棋游戏初步完成 实现功能:输入位置数据->打印棋盘->判断是否胜利->继续游戏/退出游戏 缺点:没有清屏函数   判断胜利方法太过无脑    package MYGAME; ...

  5. 2.java容器的设计模式

    目录 1.collection接口中的迭代器模式 2.迭代器模式 1.collection接口中的迭代器模式 迭代器分析: Iterator接口有hasNext().next(),remove()三个 ...

  6. js获取手机唯一标识码

    Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI.IMSI.型号.厂商等.通过plus.device获取设备信息管理对象. imei: 设备的国际移动设备身份码 imsi: 设备的 ...

  7. emacs 缩进

    emacs提供一些编码风格,可以使用M-x c-set-style来选择你喜欢的编码风格. Possible completions are: awk bsd cc-mode ellemtel gnu ...

  8. [Go] 写文件和判断文件是否存在

    OpenFile得到一个File,然后调用它的Write,参数是字节切片Stat看看返回错误没有 package main import ( "fmt" "os" ...

  9. centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够

    问题描述: centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够 解决方案:先进入bin目录 [root@localhost/]# cd ...

  10. OpenTelemetry项目中的Observability

    最近,在实操zipkin,jaeger,opencensus,opentracing,opentelemetry等. opentelemetry将Observability提到了重要页面, 并进行了讲 ...