链接:https://www.nowcoder.com/acm/contest/185/F
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
输入一个整数X,求一个整数N,使得N!恰好大于XX。
输入描述:
第一行:一个整数X
输出描述:
第一行:一个整数N
示例1
输入
7
输出
10
备注:
每个测试点所对应的X满足:
第i个测试点输入的值为第i-1个测试点输入的值乘以10再加上7。
特别的,第一个测试点所输入的值为7。
提示:数据共有10组。
/*
string数+二分
*/
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#define INF 0x3f3f3f3
using namespace std;
typedef long long LL;
typedef long double LB;
const int maxn=5e6+5;
const double pi=acos(-1.0);
const double e=exp(1);
LL X;
double String(LL x)
{
return log(2*pi*x)/2+x*log(x/e);
}
int main()
{
scanf("%lld",&X);
LL l,r,mid;
l=0,r=2*X;
while(r>l+1)
{
mid=(r+l)>>1;
if(String(mid)>=(double)X*log(X))r=mid;
else l=mid;
}
printf("%lld\n",r);
return 0;
}