POJ-2661Factstone Benchmark
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 5577 | Accepted: 2524 |
Description
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
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
Sample Input
- 1960
- 1981
- 0
Sample Output
- 3
- 8
Source
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的更多相关文章
- POJ 2661Factstone Benchmark(斯特林公式)
链接:传送门 题意:一个人自命不凡,他从1960年开始每10年更新一次计算机的最长储存长数.1960年为4位,每10年翻一倍.给出一个年份y,问这一年计算机可以执行的n!而不溢出的最大n值 思路:如果 ...
- poj 2661 Factstone Benchmark (Stirling数)
//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1. log2(n!) = log2(1) + lo ...
- poj 2661 Factstone Benchmark
/** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...
- poj 1502 最短路+坑爹题意
链接:http://poj.org/problem?id=1502 MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Subm ...
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...
- (poj)1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor A ...
- 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 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
随机推荐
- Sql ----- sqlserver 中的if 判断 case... when
与查询放到一块使用: 语法: select case when 范围条件 then 产生的结果 when 范围条件 then 产生的结果 else 不是以上范围产生的结果 end from 表名 个人 ...
- Docker学习——Dockerfile
上一篇我们讲了docker的基本使用,掌握了前一篇,docker使用基本不成问题,但是要是你学习了Dockerfile,你会发现它使用起来有多方便了.项目最终部署时,我们希望docker容器打开时项目 ...
- gRPC+gRPC Gateway+swagger小记
前言 本文记录了grpc-gateway的简单使用. 定义proto 先来看看最常规的 syntax = "proto3"; package protos; service Gre ...
- Python3---爬虫Post传参
前言 Python3 Post 传参主要用到的是urllib.request.urlopen(url,data)参数当中data.data参数主要是设置post的传参. 修改时间:20191218 天 ...
- JAVA的基本语法1
1.关键字 关键字的定义和特点 定义:被JAVA语言赋予了特殊含义,用作专门用途的字符串(单词). 就是在java语言编程的时候,在关键的地方使用的单词,体现关键的地方的含义.这些单词都是特有的,并且 ...
- Python【day 14-3】二分法查找
#二分法查找 #方法1 循环+左右边界变动,两者差减半 #方法2 递归+新列表长度减半 #方法3 递归+左右边界变动,两者差减半 #方法1 循环+左右边界变动,两者差减半 def recursion1 ...
- DB2 catalog 编目
(步骤)ap用户: (1)进入db2 db2 (2)catalog database 命令 catalog db list (3)查看本地节点目录.IP.节点名.服务名称.目录条目类型 list no ...
- 【OOM】解决思路
一.什么是OOM? OOM就是outOfMemory,内存溢出!可能是每一个java人员都能遇到的问题!原因是堆中有太多的存活对象(GC-ROOT可达),占满了堆空间. 二.怎么解决? 1.拿到内存溢 ...
- Netty与RPC
一.Netty原理 Netty是一个高性能.异步事件驱动的NIO框架,基于Java NIO提供的API实现.它提供了对TCP.UDP和文件传输的支持,作为一个异步NIO框架,Netty的所有IO操作都 ...
- IntelliJ IDEA UML插件
在IntelliJ IDEA Ultimate 版本中自带了一个UML插件:UMLSupport 查看了Community版本和AndroidStudio 发现没有这个插件. 要使用这个插件导出需要的 ...