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 做到有 ...
随机推荐
- ZOJ 2588 Burning Bridges (tarjan求割边)
题目链接 题意 : N个点M条边,允许有重边,让你求出割边的数目以及每条割边的编号(编号是输入顺序从1到M). 思路 :tarjan求割边,对于除重边以为中生成树的边(u,v),若满足dfn[u] & ...
- ExtJs之addManagedListener
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- Windows X64 Patch Guard
先简单介绍下PatchGuard ,摘自百度百科 PatchGuard就是Windows Vista的内核保护系统,防止任何非授权软件试图“修改”Windows内核,也就是说,Vista内核的新型金钟 ...
- Django视频教程 - 基于Python的Web框架(全13集)
Django是由Python驱动的开源模型-视图-控制器(MVC)风格的Web应用程序框架,使用Django可以在即可分钟内快速开发一个高品质易维护数据库驱动的应用程序.下面是一大坨关于Django应 ...
- 内存就是RAM?
内存不全是RAM,让我们看看当今的Intel计算机是如何连接各个组件的吧.下图展示了主板上的主要组件: 现代主板的示意图,北桥和南桥构成了芯片组. 当你看图时,请牢记一个至关重要的事实:CPU一点也不 ...
- mq_send
NAME mq_send - 将消息发送到消息队列 (REALTIME) SYNOPSIS #include <mqueue.h>int mq_send(mqd_t mqdes, cons ...
- Android 核心分析 之八Android 启动过程详解
Android 启动过程详解 Android从Linux系统启动有4个步骤: (1) init进程启动 (2) Native服务启动 (3) System Server,Android服务启动 (4) ...
- JavaPersistenceWithHibernate第二版笔记Getting started with ORM-002Domain层详解及M etaModel
一.结构 二.配置文件约定 The JPA provider automatically picks up this descriptor if you place it in a META-INF ...
- 创业者拿到融资别高兴太早,当心TS中的优先清算权
最近创投圈的新闻读起来真是让人有些绝望啊,一家家创业公司接连宣告倒闭,其中不乏一些走在比较后面的“明星企业”,冷不丁冒出点消息,却是创始人发的公告,宣布公司资金链断裂,进入破产清算程序,或被低价并购. ...
- 世界上还有一个东西叫Virtual Pascal
官网是:http://web.archive.org/web/20060312064321/http://www.vpascal.com/news.php?item.16 不过2005年就不再维护了. ...