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

  1. 1960
  2. 1981
  3. 0

Sample Output

  1. 3
  2. 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:

  1. #include<cstdio>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. int n;
  7. double w;
  8. while(~scanf("%d",&n)&&n) {
  9. w=log();
  10. for(int i=;i<=n;i+=) {
  11. w*=;
  12. }
  13. int i=;
  14. double f=;
  15. while(f<w) {
  16. f+=log((double)++i);
  17. }
  18. printf("%d\n",i-);
  19. }
  20. }

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. Sql ----- sqlserver 中的if 判断 case... when

    与查询放到一块使用: 语法: select case when 范围条件 then 产生的结果 when 范围条件 then 产生的结果 else 不是以上范围产生的结果 end from 表名 个人 ...

  2. Docker学习——Dockerfile

    上一篇我们讲了docker的基本使用,掌握了前一篇,docker使用基本不成问题,但是要是你学习了Dockerfile,你会发现它使用起来有多方便了.项目最终部署时,我们希望docker容器打开时项目 ...

  3. gRPC+gRPC Gateway+swagger小记

    前言 本文记录了grpc-gateway的简单使用. 定义proto 先来看看最常规的 syntax = "proto3"; package protos; service Gre ...

  4. Python3---爬虫Post传参

    前言 Python3 Post 传参主要用到的是urllib.request.urlopen(url,data)参数当中data.data参数主要是设置post的传参. 修改时间:20191218 天 ...

  5. JAVA的基本语法1

    1.关键字 关键字的定义和特点 定义:被JAVA语言赋予了特殊含义,用作专门用途的字符串(单词). 就是在java语言编程的时候,在关键的地方使用的单词,体现关键的地方的含义.这些单词都是特有的,并且 ...

  6. Python【day 14-3】二分法查找

    #二分法查找 #方法1 循环+左右边界变动,两者差减半 #方法2 递归+新列表长度减半 #方法3 递归+左右边界变动,两者差减半 #方法1 循环+左右边界变动,两者差减半 def recursion1 ...

  7. DB2 catalog 编目

    (步骤)ap用户: (1)进入db2 db2 (2)catalog database 命令 catalog db list (3)查看本地节点目录.IP.节点名.服务名称.目录条目类型 list no ...

  8. 【OOM】解决思路

    一.什么是OOM? OOM就是outOfMemory,内存溢出!可能是每一个java人员都能遇到的问题!原因是堆中有太多的存活对象(GC-ROOT可达),占满了堆空间. 二.怎么解决? 1.拿到内存溢 ...

  9. Netty与RPC

    一.Netty原理 Netty是一个高性能.异步事件驱动的NIO框架,基于Java NIO提供的API实现.它提供了对TCP.UDP和文件传输的支持,作为一个异步NIO框架,Netty的所有IO操作都 ...

  10. IntelliJ IDEA UML插件

    在IntelliJ IDEA Ultimate 版本中自带了一个UML插件:UMLSupport 查看了Community版本和AndroidStudio 发现没有这个插件. 要使用这个插件导出需要的 ...