题目来源:Light OJ 1234 Harmonic Number
题意:
思路:没思路啊 这个是高数的东西 发散 n足够大时它无穷大 直接公式解
#include <cstdio> #include <cstring> #include <cmath> #include <string> #include <algorithm> #include <iostream> using namespace std; const int maxn = 1000010; const double phi = 0.57721566490153286060651209; double a[maxn]; int main() { for(int i = 1; i <= 1000000; i++) a[i] = a[i-1] + 1.0/i; int cas = 1; int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); double ans; if(n <= 1000000) ans = a[n]; else ans = log(n+0.5) + phi; printf("Case %d: %.10lf\n", cas++, ans); } return 0; }
Light OJ 1234 Harmonic Number 调和级数部分和,布布扣,bubuko.com
Light OJ 1234 Harmonic Number 调和级数部分和
原文地址:http://blog.csdn.net/u011686226/article/details/26842709