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 ...
随机推荐
- rpmrebuild 下载安装
下载 https://jaist.dl.sourceforge.net/project/rpmrebuild/rpmrebuild/2.14/rpmrebuild-2.14.tar.gz 安装 将其做 ...
- org.springframework.util.Base64Utils线程安全问题
Spring提供的org.springframework.util.Base64Utils类,先会检测JDK里是否自带java.util.Base64,如果不带,则使用的是apache提供的org.a ...
- ABAP 新语法记录(一)
原文链接:https://www.cnblogs.com/learnning/p/10647174.html 主要内容 内联声明 构造表达式 内表操作 Open SQL 其他 本文列出了ABAP新语法 ...
- struts图片上传
文件上传:三种上传方案1.上传到tomcat服务器 上传图片的存放位置与tomcat服务器的耦合度太高2.上传到指定文件目录,添加服务器与真实目录的映射关系,从而解耦上传文件与tomcat的关系文件服 ...
- Linux网络——配置网络之iproute家族命令
Linux网络——配置网络之iproute家族命令 摘要:本文主要学习了iproute家族用来配置网络的命令. ip命令 ip命令用于查看和管理IP地址.接口.路由.隧道等.用来取代ifconfig命 ...
- LinuxShell脚本——选择结构
LinuxShell脚本——选择结构 摘要:本文主要学习了Shell脚本中的选择结构. if-else语句 基本语法 最简单的用法就是只使用if语句,它的语法格式为: if 条件 then 命令 fi ...
- Java日期时间API系列5-----Jdk7及以前的日期时间类TimeUnit在并发编程中的应用
TimeUnit是一个时间单位枚举类,主要用于并发编程,时间单元表示给定粒度单元的时间持续时间,并提供实用程序方法来跨单元转换,以及在这些单元中执行计时和延迟操作. 1.时间单位换算 (1)支持的单位 ...
- Redis Python(一)
Infi-chu: http://www.cnblogs.com/Infi-chu/ NoSQL(NoSQL=Not Only SQL),中文意思是非关系型数据库. 随着互联网Web2.0网站的兴起, ...
- Python使用DB-API操作MySQL数据库
Python提供了一个标准数据库API,称为DB-API,用于处理基于SQL的数据库.与任何底层数据库的交互都可以使用DB-API,因为DB-API在代码与驱动程序之间提供了一个抽象层,可以根据需要替 ...
- js实现textarea自适应高度
html结构: <div class="container" id="container"> <div class="text-wr ...