P2759 奇怪的函数
题目描述
使得 xxx^xxx 达到或超过 nnn 位数字的最小正整数 xxx 是多少?
输入格式
一个正整数 nnn。
输出格式
使得 xxx^xxx 达到 nnn 位数字的最小正整数 xxx。
输入输出样例 #1
输入 #1
11
输出 #1
10
说明/提示
对于全部数据,1≤n≤2×1091\le n\le 2\times 10^91≤n≤2×109。
C++实现
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define LL long long int
using namespace std;
int main(){
int n;
LL L=1,R=2e9;
cin>>n;
while(L<R){
LL mid=(L+R)>>1,len=(LL)(mid*log10(1.0*mid))+1;
if(len<n) L=mid+1;
else R=mid;
}
cout<<L<<endl;
return 0;
}

后续
接下来我会不断用C++来实现信奥比赛中的算法题、GESP考级编程题实现、白名单赛事考题实现,记录日常的编程生活、比赛心得,感兴趣的请关注,我后续将继续分享相关内容

被折叠的 条评论
为什么被折叠?



