传送门

题意:

给出\(x,x\leq 12\),求最大的\(n\),满足\(n!\leq 2^{2^x}\)。

思路:

通过斯特林公式:

\[n!\approx \sqrt{2\pi n}\cdot (\frac{n}{e})^n
\]

我们一般可以认为这两个相等= =

将阶乘转化为一个比较好求的式子,然后二分判断一下即可。

/*
* Author: heyuhhh
* Created Time: 2019/12/10 21:14:22
*/
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
#define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
void err() { std::cout << '\n'; }
template<typename T, typename...Args>
void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
#define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5; int n; bool chk(double x) {
return 0.5 * log(2 * 3.1415926 * x) + x * log(x) - x <= pow(2, n) * log(2);
} void run(){
if(n == 0) return;
n = (n - 1940) / 10 * 10 / 10;
double l = 1, r = 1000000000000000, mid;
for(int i = 0; i < 1000; i++) {
mid = (l + r) / 2;
if(chk(mid)) l = mid;
else r = mid;
}
cout << (ll)l << '\n';
} int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cout << fixed << setprecision(20);
while(cin >> n) run();
return 0;
}

【poj2661】Factstone Benchmark(斯特林公式)的更多相关文章

  1. poj2661 Factstone Benchmark(大数不等式同取对数)

    这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log ...

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

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

  3. HDU 1141 Factstone Benchmark (数学 )

    题目链接 Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a ...

  4. Factstone Benchmark

    [问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了6 ...

  5. poj 2661 Factstone Benchmark (Stirling数)

    //题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1.   log2(n!) = log2(1) + lo ...

  6. sicily 1119 Factstone Benchmark

    题意:求满足n! < 2^k,n的最大值! 解题:指数比较转换成对数比较,达到降幂! 其中: log (n!) = log(n)+log(n-1)+...+log(1); log(2^k) = ...

  7. poj 2661 Factstone Benchmark

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

  8. Factstone Benchmark(数学)

    http://poj.org/problem?id=2661 题意:Amtel在1960年发行了4位计算机,并实行每十年位数翻一番的策略,将最大整数n作为改变的等级,其中n!表示计算机的无符号整数(n ...

  9. POJ-2661Factstone Benchmark

    Factstone Benchmark Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5577   Accepted: 25 ...

随机推荐

  1. 为什么delete后磁盘空间没有释放而truncate会释放?

    背景 因项目需求,需要清理一批旧数据,腾出空间给新数据,让同事负责这件事.料想会很顺利,但很快找到我,并告知在postgresql中把一张大的数据表删除掉了,查询表的size并没有改变. 我震惊了,问 ...

  2. IDEA 下使用JSTL 非maven

    原文链接:https://www.cnblogs.com/xiehang/p/9430342.html 习惯了eclipse和myeclipse开发的我们总是依赖于系统的插件,而当我想当然的以为Int ...

  3. Filter List Views 筛选器列表视图

    In this lesson, you will learn how to filter a List View. Three techniques, based on different scena ...

  4. leaflet 结合 Echarts4 实现迁徙图(附源码下载)

    前言 leaflet 入门开发系列环境知识点了解: leaflet api文档介绍,详细介绍 leaflet 每个类的函数以及属性等等 leaflet 在线例子 leaflet 插件,leaflet ...

  5. Android PopupWindow增加半透明蒙层

    先看效果图: BasePopupWindowWithMask.class package com.example.popupwindowwithmask; import android.content ...

  6. Vue之富文本tinymce爬坑录

    前言 最近因业务需求在项目中嵌入了tinymce这个富文本编辑器,用于满足平台给用户编辑各类新闻内容什么的业务需求,前后也花了不少时间体验和对比了市面上各类开源编辑器. *案例demo版本:vue-t ...

  7. Git介绍与简易搭建

    Git介绍 Git(读音为/gɪt/.)是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发 ...

  8. 为什么 netstat 对某些服务只显示了 tcp6 监听端口

    最近偶尔发现一个比较奇怪的现象,netstat 查看监听的服务端口时,却只显示了 tcp6 的监控, 但是服务明明是可以通过 tcp4 的 ipv4 地址访问的,那为什么没有显示 tcp4 的监听呢? ...

  9. vue项目、路由

    目录 Vue项目创建 pycharm配置并启动vue项目 vue项目目录结构分析 js原型补充 vue项目生命周期 页面组件 配置自定义全局样式 路由逻辑跳转 路由重定向 组件的生命周期钩子 路由传参 ...

  10. maven与gradle的阿里云仓库配置

    直接参考 https://help.aliyun.com/document_detail/102512.html 就好. 阿里云maven仓库官网 https://maven.aliyun.com/m ...