整数性质和精度测试

时间:2014-04-30 19:46:56   收藏:0   阅读:411

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

bubuko.com,布布扣
 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

 

整数性质和精度测试,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!