您的位置:首页 > 理论基础 > 计算机网络

http://projecteuler.net/problem=29 [Answer:9183]

2011-11-29 23:53 531 查看
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
const int N = 100;
double dLogValue[N*N];
int count = 0;

for ( int a = 2; a <= N; ++a )
{
double d = log( static_cast<double>(a) );
double x = d;
for ( int b = 2; b <= N; ++b )
{
x += d;
dLogValue[count++] = x;
}
}

sort( dLogValue, dLogValue+count );

const double epsilon = 1e-12;
int result = 1;
for ( int i = 1; i < count; ++i )
{
if ( dLogValue[i] - dLogValue[i-1] > epsilon )
{
result++;
}
}

cout << result << endl;
return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  include