首页 > 代码库 > 整数性质和精度测试

整数性质和精度测试

题目:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=612

 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){
22 //      for(n=1;n<=100000;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 }
View Code