POJ-2661Factstone Benchmark
时间:2019-10-10
本文章向大家介绍POJ-2661Factstone Benchmark,主要包括POJ-2661Factstone Benchmark使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
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?
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:
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(4); for(int i=1960;i<=n;i+=10) { w*=2; } int i=1; double f=0; while(f<w) { f+=log((double)++i); } printf("%d\n",i-1); } }
原文地址:https://www.cnblogs.com/cautx/p/11651140.html
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- moco固定QPS接口升级补偿机制
- 大小端示例-arm c51
- #define的一个小技巧
- 干货 | 手把手教你用115行代码做个数独解析器!
- Ubuntu18.04 ROS安装小记
- 面试题系列第7篇:Java方法到底是值传递还是引用传递?
- input输入框内容规范正则总结
- 【干货满满】1.5w字初中级前端面试复习总结
- 娱乐圈排行榜动态条形图绘制
- vue3.0的 v-model 为啥不好用了?
- SHELL命令分组统计
- 一行代码实现display"过渡动画"原理
- 3D星空图
- shading-jdbc 4.1.1 + tk.mybatis + pagehelper 1.3.x +spring boot 2.x 使用注意事项
- 用辗转相除法求两个正整数的最大公约数