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 做到有 ...
随机推荐
- MySQL Date 函数
MySQL Date 函数 下面的表格列出了 MySQL 中最重要的内建日期函数: 函数 描述 NOW() 返回当前的日期和时间 CURDATE() 返回当前的日期 CURTIME() 返回当前的时间 ...
- 2014多校第七场1005 || HDU 4939 Stupid Tower Defense (DP)
题目链接 题意 :长度n单位,从头走到尾,经过每个单位长度需要花费t秒,有三种塔: 红塔 :经过该塔所在单位时,每秒会受到x点伤害. 绿塔 : 经过该塔所在单位之后的每个单位长度时每秒都会经受y点伤害 ...
- ExtJs布局之tabPanel
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- Heroku 与 ASP.NET 5
一. Heroku 简单来讲,Heroku是一个支持多种语言.极易部署.多价位可免费的 Pass 平台,通过 Buildpack 搭建语言运行环境, 默认内建的大部分是 Web 开发中较为常见的语言, ...
- android真机自动化测试
appium执行用例时报错问题: 问题解析: 一般该种情况都是因为来连接了多个设备,验证办法:cmd->执行adb devices 看结果是否是多个devices ,如果是这个问题,停掉多余设 ...
- sublime3可用key
—– BEGIN LICENSE —–Nicolas HennionSingle User LicenseEA7E-8660758A01AA83 1D668D24 4484AEBC 3B04512C8 ...
- Linux 与 CONE NAT 和 Symmetric NAT
http://alexanderlaw.blog.hexun.com/31883661_d.html 1. NAT 的划分 RFC3489 中将 NAT 的实现分为四大类: 1. Full Cone ...
- intellij idea搭建ssh开发框架之绑定数据源
原文:intellij idea搭建ssh开发框架之绑定数据源 在intellij idea中绑定数据源并生成hibernate实体对象.在IDE中的右边找到Database标签. 点击弹出窗口中的图 ...
- 在Ogre中加载自己的资源包
转自:http://www.cnblogs.com/minggoddess/archive/2011/02/19/1958472.html 由于数据保护的需要,一款游戏一般都会有自己独有的资源包,这样 ...
- iOS:UIAlertController和UIAlertAction的详解
提示框控制器:UIAlertController 提示框按钮:UIAlertAction 功能:用来提示信息,并给出一些可以进行选择的按钮来处理相应的要求. 注意:在Xcode的iOS8 SD ...