poj 2661 Factstone Benchmark (Stirling数)
//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n
//两边同取以二为底的对数,可得: lg2(n!) <= 2^x
1.
log2(n!) = log2(1) + log2(2) + .. + log2(n);一个循环即可
2.
Stirling

#include <iostream>
#include <string>
#include<sstream>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
// #define LL __int64
#define LL long long
const double pi=acos(-1.0);
const double inx_2=log(2.0); // log -> inx log10
int f[];
int main()
{
f[]=;
int i;
for(i=;i<;i++)
f[i]=f[i-]*;
int year;
while(scanf("%d",&year),year)
{
double t=f[(year-)/+];
double s=(0.5*log(*pi)+log(1.0)-)/inx_2;
i=;
while(s<=t)
{
i++;
s=(0.5*log(*pi*i)+i*log((double)i)-i)/inx_2;
}
printf("%d\n",i-);
}
return ;
}
poj 2661 Factstone Benchmark (Stirling数)的更多相关文章
- poj 2661 Factstone Benchmark
/** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...
- 【noi 2.6_9283】&【poj 3088】Push Botton Lock(DP--排列组合 Stirling数)
题意:N个编号为1~N的数,选任意个数分入任意个盒子内(盒子互不相同)的不同排列组合数. 解法:综合排列组合 Stirling(斯特林)数的知识进行DP.C[i][j]表示组合,从i个数中选j个数的方 ...
- uva 10916 Factstone Benchmark(对数函数的活用)
Factstone Benchmark Amtel has announced that it will release a 128-bit computer chip by 2010, a 256- ...
- lightOJ 1326 Race(第二类Stirling数)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1326 题意:有n匹马赛跑.问有多少种不同的排名结果.可以有多匹马的排名相同. 思路:排 ...
- 斯特灵数 (Stirling数)
@维基百科 在组合数学,Stirling数可指两类数,都是由18世纪数学家James Stirling提出的. 第一类 s(4,2)=11 第一类Stirling数是有正负的,其绝对值是个元素的项目分 ...
- hdu 4372 第一类stirling数的应用/。。。好题
/** 大意: 给定一系列楼房,都在一条水平线上,高度从1到n,从左侧看能看到f个, 从右侧看,能看到b个,问有多少种这样的序列.. 思路: 因为肯定能看到最高的,,那我们先假定最高的楼房位置确定,那 ...
- HDU 3625 Examining the Rooms:第一类stirling数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3625 题意: 有n个房间,每个房间里放着一把钥匙,对应能开1到n号房间的门. 除了1号门,你可以踹开任 ...
- HDU 4372 Count the Buildings:第一类Stirling数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4372 题意: 有n栋高楼横着排成一排,各自的高度为1到n的一个排列. 从左边看可以看到f栋楼,从右边看 ...
- 整理一点与排列组合有关的问题[组合数 Stirling数 Catalan数]
都是数学题 思维最重要,什么什么数都没用,DP直接乱搞(雾.. 参考LH课件,以及资料:http://daybreakcx.is-programmer.com/posts/17315.html 做到有 ...
随机推荐
- ExtJs尝下鲜
感觉进入了一个新天地. WIN时代的API + 浏览器的窗口. 复古风了? 真的是好多年前还有点印象的DELPHI及MFC啊. <!DOCTYPE html> <html> & ...
- VS2003 下GridControl的列显示成图片+文字的形式实现
public RC_CustomerSolicitListUC() { // 该调用是 Windows.Forms 窗体设计器所必需的. InitializeComponent(); // TODO: ...
- a cold welcome
What does 'a cold welcome' refer to? On wednesday evening,we went to the town hall. It was the last ...
- Struts2笔记——第一个实例HelloWorld
1.创建新的Dynamic Web项目 ------------------------------------------ 2.struts2框架配置 ------------------- ...
- Box2d学习
Box2d 学习 . Testbed 项目: Testbed 是 Box2d 源码里包含的一个例子程序.Testbed 封装了界面显示.游戏循环等部分的代码.添加新的例子的时候,只需要关注与 Box ...
- 返回Json数据浏览器带上<pre></pre>标签解决方法
问题: 当后台获取到前台传来的文件时(例如上传功能, 导入功能), 返回类型为application/json, 这个时候响应到前端的JSON格式的数据格式可能是: <pre style=&q ...
- 非root模式下安装mysql
1. 下载mysql.tar.gz wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz 2. 下载cmake [ ...
- python实现全角半角的相互转换
缘起 在自然语言处理过程中,全角.半角的的不一致会导致信息抽取不一致,因此需要统一. 转换说明 全角半角转换说明 有规律(不含空格): 全角字符unicode编码从65281~65374 (十六进制 ...
- form提交的时候使用method=get导致乱码
一个a.jsp提交给b.jsp, b.jsp中使用 request.setCharacterEncoding("UTF-8"); 解决乱码 a.jsp中的form忘了写method ...
- Spring Boot MyBatis 通用Mapper插件集成
Mybatis在使用过程中需要三个东西,每张表对应一个XXMapper.java接口文件,每张表对应一个XXMapper.xml文件,每张表对应一个Entity的Java文件. 其中XXMappe ...