您的位置:首页 > 其它

poj 2661(关于对数log的应用)

2012-12-09 09:39 363 查看
题目链接:http://poj.org/problem?id=2661

利用:

2^n<1*2*3...m

n<log21+log22+log23.....然后换底公式

代码:

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int find(int n){
double t=pow((double)2,(n-1960)/10+2),sum=0;
int i=0;
for(i=2;sum<t;i++){
sum+=log((double)i)/log((double)2);
}
return i-2;
}
int main(){
int n=0;
while(scanf("%d",&n)&&n){
printf("%d\n",find(n));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: