題目來源:Light OJ 1234 Harmonic Number
題意:
思路:沒思路啊 這個是高數的東西 發散 n足夠大時它無窮大 直接公式解
#include#include #include #include #include #include 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; }