【题目】:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=612
【题意】:
求X^X(X的X次方)达到n位时最小x的值。
【分析】:首先我们可以知道位数和X的大小成正相关。
我们不可能枚举这个x,那么就要二分。
然后怎么知道x^2有多少位呢?
k=(x+0.0)*log10(x)+1 其实就是10的位数
【输入】:多组测试数据,每组数据占一行包含一个整数n,1<=n<=100000000.
【代码】:
1 /*http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=612 2 关键是对数处理位数 3 */ 4 #include <iostream> 5 #include <stdio.h> 6 #include <math.h> 7 #include <vector> 8 #define eps 1e-15 9 #define LL long long 10 #define INF 1e9 11 using namespace std; 12 13 LL F(LL x){ 14 if (x==1) return 1; 15 double k=(x+0.0)*log10(x); 16 return (LL)k+1; 17 } 18 LL n; 19 int main(){ 20 // freopen("out.txt","w",stdout); 21 while(cin>>n){ 23 LL l=0,r=INF,times=0; 24 while(l<r && times<70){ 25 times++; 26 LL m=l+(r-l)/2; 27 if (F(m)>=n) r=m;else l=m+1; 28 } 29 cout<<l<<endl; 30 } 31 return 0; 32 }