博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2661 Factstone Benchmark (Stirling数)
阅读量:4583 次
发布时间:2019-06-09

本文共 785 字,大约阅读时间需要 2 分钟。

//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n

//两边同取以二为底的对数,可得: lg2(n!) <= 2^x

 1.

   log2(n!) = log2(1) + log2(2) + .. + log2(n);一个循环即可

 2.

   Stirling

    

#include 
#include
#include
#include
#include
#include
#include
#include
using namespace std;// #define LL __int64#define LL long longconst double pi=acos(-1.0);const double inx_2=log(2.0); // log -> inx log10int f[30];int main(){ f[0]=1; int i; for(i=1;i<30;i++) f[i]=f[i-1]*2; int year; while(scanf("%d",&year),year) { double t=f[(year-1960)/10+2]; double s=(0.5*log(2*pi)+log(1.0)-1)/inx_2; i=1; while(s<=t) { i++; s=(0.5*log(2*pi*i)+i*log((double)i)-i)/inx_2; } printf("%d\n",i-1); } return 0;}

 

转载于:https://www.cnblogs.com/372465774y/p/3607310.html

你可能感兴趣的文章
直角三角形 (Standard IO)
查看>>
web 12
查看>>
Centos7安装Nginx
查看>>
探讨在线支付平台支付接口的设计
查看>>
【设计模式】常用设计模式总结
查看>>
.NET中的六个重要概念
查看>>
二十九、简谈设计模式
查看>>
js中数组的检测方法
查看>>
[译]GotW #6a: Const-Correctness, Part 1
查看>>
JAVA基础学习之 Map集合、集合框架工具类Collections,Arrays、可变参数、List和Set集合框架什么时候使用等(4)...
查看>>
用Python学分析 - 单因素方差分析
查看>>
2018个人年终总结
查看>>
[编辑排版]小技巧---markdown 转 richText
查看>>
JSON_UNESCAPED_UNICODE
查看>>
bug解决思路
查看>>
Oracle没有WM_CONCAT函数的解决办法
查看>>
消息中间件——RabbitMQ(四)命令行与管控台的基本操作!
查看>>
Eclipse 写代码是自动重启服务
查看>>
3.8 spring - AbstractBeanDefinition 介绍
查看>>
如何在Visual Studio里面查看程序的汇编代码?
查看>>