1. LightOJ 1234 tabulation (the data size is too large, which is reduced by 100 times), lightoj1234
Original question link http://acm.hust.edu.cn/vjudge/contest/121397#problem/A
Meaning: t group data. For each group of data, calculate the sum of 1 + 1/2 + 1/3 + 1/4... + 1/n.
Method: Do not store one of the 100 tables. If the number is less than 100, run it.
# Include <iostream>
# Include <cstdio>
# Include <cstring>
# Include <algorithm>
# Include <stack>
# Include <queue>
# Include <math. h>
# Include <vector>
Using namespace std;
# Define N 1001010
# Define ll long
# Define INF 0x3f3f3f
# Define met (a, B) memset (a, B, sizeof ());
Vector <int> Q;
Double sum [N];
Void init ()
{
Sum [0] = 0;
Sum [1] = 1.0;
Double ans = 1.0;
For (int I = 2; I <= 100000009; I ++)
{
Ans + = 1.0/(I * 1.0 );
If (I % 100 = 0)
Sum [I/100] = ans;
}
}
Int main ()
{
Init ();
Int t, l, con = 1;
Scanf ("% d", & t );
While (t --)
{
Ll n;
Scanf ("% lld", & n );
L = n/100;
Double ans = sum [l];
For (int I = l * 100 + 1; I <= n; I ++)
Ans + = 1.0/(I * 1.0 );
Printf ("Case % d: %. 10f \ n", con ++, ans );
}
Return 0;
}