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; }
相关文章推荐
- http://projecteuler.net/problem=38 [Answer:932718654]
- http://projecteuler.net/problem=16 [Answer:1366]
- http://projecteuler.net/problem=17 [Answer:21124]
- http://projecteuler.net/problem=32 [Answer:45228]
- http://projecteuler.net/problem=18 [Answer:1074]
- http://projecteuler.net/problem=23 [Answer:4179871]
- http://projecteuler.net/problem=26 [Answer:983]
- http://projecteuler.net/problem=35 [Answer:55]
- http://projecteuler.net/problem=27 [Answer:-59231]
- http://projecteuler.net/problem=36 [Answer:872187]
- http://projecteuler.net/problem=39 [Answer:840]
- http://projecteuler.net/problem=30 [Answer:443839]
- http://projecteuler.net/problem=28 [Answer:669171001]
- http://projecteuler.net/problem=34 [Answer:40730]
- http://projecteuler.net/problem=5 [Answer:232792560]
- http://projecteuler.net/problem=14 [Answer:837799]
- http://projecteuler.net/problem=19 [Answer:171]
- http://projecteuler.net/problem=25 [Answer:4782]
- http://projecteuler.net/problem=6 [Answer:25164150]
- http://projecteuler.net/problem=20 [Answer:648]