poj 2661 Factstone Benchmark
/**
大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n
即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = n
枚举即可 拓展:
可以用斯特林(Stirling)公式求解 斯特林(Stirling)公式: log(x) =====ln(x) **/
#include <iostream>
#include <cmath>
using namespace std; int main()
{
int y;
while(cin>>y&&y){
int t = <<((y-)/+);
double m=;
double res =log(m)/log(2.0);
while(res<=t){
m++;
res += log(m)/log(2.0) ;
}
cout<<m-<<endl;
}
return ;
}
poj 2661 Factstone Benchmark的更多相关文章
- poj 2661 Factstone Benchmark (Stirling数)
//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1. log2(n!) = log2(1) + lo ...
- uva 10916 Factstone Benchmark(对数函数的活用)
Factstone Benchmark Amtel has announced that it will release a 128-bit computer chip by 2010, a 256- ...
- HDU 1141 Factstone Benchmark (数学 )
题目链接 Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a ...
- Factstone Benchmark(数学)
http://poj.org/problem?id=2661 题意:Amtel在1960年发行了4位计算机,并实行每十年位数翻一番的策略,将最大整数n作为改变的等级,其中n!表示计算机的无符号整数(n ...
- Factstone Benchmark
[问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了6 ...
- sicily 1119 Factstone Benchmark
题意:求满足n! < 2^k,n的最大值! 解题:指数比较转换成对数比较,达到降幂! 其中: log (n!) = log(n)+log(n-1)+...+log(1); log(2^k) = ...
- POJ 2661
#include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("a ...
- poj2661 Factstone Benchmark(大数不等式同取对数)
这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log ...
- 【poj2661】Factstone Benchmark(斯特林公式)
传送门 题意: 给出\(x,x\leq 12\),求最大的\(n\),满足\(n!\leq 2^{2^x}\). 思路: 通过斯特林公式: \[ n!\approx \sqrt{2\pi n}\cdo ...
随机推荐
- 算法导论练习6.5-8 k路合并
题目: 请给出一个时间为O(nlgk).用来将k个已排序链表合并为一个排序链表的算法.此处n为所有输入链表中元素的总数.(提示:用一个最小堆来做k路合并. 看到题目第个想到的是归并排序过程中的归并操作 ...
- perl lwp get uft-8和gbk
gbk编码: jrhmpt01:/root/lwp# cat x2.pl use LWP::UserAgent; use DBI; $user="root"; $passwd='R ...
- 在 Visual C++ 中开发自定义的绘图控件
本文讨论的重点介于两者 之间 — 公共控件赋予您想要的大部分功能,但控件的外观并不是您想要的.例如,列表视图控件提供在许多视图风格中显示数据列表的方式 — 小图标.大图标.列表和详细列表(报告).然而 ...
- mysql的函数
- Linux学习笔记之权限与命令之间的关系(重要)及文件与文件夹知识总结
一.让使用者能进入某文件夹成为可工作文件夹的基本权限为何: 可使用的命令:比如 cd 等变换工作文件夹的命令. 文件夹所需权限:使用者对这个文件夹至少须要具有 x的权限 额外需求:假设使用者想要在这个 ...
- MD5的加密和解密(总结)
效果图例如以下: package com.test; import java.security.MessageDigest; public class MD5 { // MD5加码.32位 publi ...
- 基于thinkphp的uploadify上传图功能
php Action server端 <?php /* * To change this template, choose Tools | Templates * and open the ...
- Javascript初级学习总结
首先,在Html页面输出,使用document.write('内容'); <html> <head> <title></title> <scrip ...
- hdu 3333 Turing Tree
题目链接 给n个数, m个询问, 每次询问输出区间内的数的和, 相同的数只计算一次. 数组里的数是>-1e9 <1e9, 可以把它离散以后用莫队搞... #include <iost ...
- The Standard Librarian: I/O and Function Objects: Containers of Pointers
C++ Experts Forum The Standard Librarian: I/O and Function Objects: Containers of Pointers Matthew A ...