//题意是对于给定的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数)的更多相关文章

  1. poj 2661 Factstone Benchmark

    /** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...

  2. 【noi 2.6_9283】&【poj 3088】Push Botton Lock(DP--排列组合 Stirling数)

    题意:N个编号为1~N的数,选任意个数分入任意个盒子内(盒子互不相同)的不同排列组合数. 解法:综合排列组合 Stirling(斯特林)数的知识进行DP.C[i][j]表示组合,从i个数中选j个数的方 ...

  3. uva 10916 Factstone Benchmark(对数函数的活用)

    Factstone Benchmark Amtel has announced that it will release a 128-bit computer chip by 2010, a 256- ...

  4. lightOJ 1326 Race(第二类Stirling数)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1326 题意:有n匹马赛跑.问有多少种不同的排名结果.可以有多匹马的排名相同. 思路:排 ...

  5. 斯特灵数 (Stirling数)

    @维基百科 在组合数学,Stirling数可指两类数,都是由18世纪数学家James Stirling提出的. 第一类 s(4,2)=11 第一类Stirling数是有正负的,其绝对值是个元素的项目分 ...

  6. hdu 4372 第一类stirling数的应用/。。。好题

    /** 大意: 给定一系列楼房,都在一条水平线上,高度从1到n,从左侧看能看到f个, 从右侧看,能看到b个,问有多少种这样的序列.. 思路: 因为肯定能看到最高的,,那我们先假定最高的楼房位置确定,那 ...

  7. HDU 3625 Examining the Rooms:第一类stirling数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3625 题意: 有n个房间,每个房间里放着一把钥匙,对应能开1到n号房间的门. 除了1号门,你可以踹开任 ...

  8. HDU 4372 Count the Buildings:第一类Stirling数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4372 题意: 有n栋高楼横着排成一排,各自的高度为1到n的一个排列. 从左边看可以看到f栋楼,从右边看 ...

  9. 整理一点与排列组合有关的问题[组合数 Stirling数 Catalan数]

    都是数学题 思维最重要,什么什么数都没用,DP直接乱搞(雾.. 参考LH课件,以及资料:http://daybreakcx.is-programmer.com/posts/17315.html 做到有 ...

随机推荐

  1. POJ 1279 Art Gallery(半平面交求多边形核的面积)

    题目链接 题意 : 求一个多边形的核的面积. 思路 : 半平面交求多边形的核,然后在求面积即可. #include <stdio.h> #include <string.h> ...

  2. ExtJs之Ext.util.TextMetrics

    <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...

  3. SQL Server 脚本

    创建数据库: --创建数据库 CREATE DATABASE Accounting -- 新数据库的名称 ON --主文件 ( NAME = 'Accounting', --文件名 FILENAME ...

  4. TCP/IP协议 三次握手与四次挥手【转】

    一.TCP报文格式 TCP/IP协议的详细信息参看<TCP/IP协议详解>三卷本.下面是TCP报文格式图: 图1 TCP报文格式 上图中有几个字段需要重点介绍下:        (1)序号 ...

  5. 用eclipse创建maven项目

    Maven是基于项目对象模型(POM),也可以进行模块化开发.并且是个强大的管理工具.本经验用eclipse来创建maven项目 步骤: 1.下载并正确安装eclipse 2.在eclipse上成功安 ...

  6. Shell练习 统计单词个数,降序排列

    原文:https://leetcode.com/problems/word-frequency/ Write a bash script to calculate the frequency of e ...

  7. Shell练习 行列转换

    原题:https://leetcode.com/problems/transpose-file/Given a text file file.txt, transpose its content. Y ...

  8. a cold welcome

    What does 'a cold welcome' refer to? On wednesday evening,we went to the town hall. It was the last ...

  9. c语言结构体赋值问题

    对于结构体赋值问题: static psl{ int a; char ch; }; 我过去一般会对结构体这样赋值: static psl pslname = { , 'b', }; 记住有一点,‘b’ ...

  10. jsp中的out对象 和 servlet中的response.getOutputStream()

    web容器生成的servlet代码中有out.write(””),这个和JSP中调用的response.getOutputStream()产生冲突. 即Servlet规范说明,不能既调用 respon ...