https://vjudge.net/problem/SPOJ-FAVDICE
https://blog.csdn.net/myjs999/article/details/81022546
1 #define IO std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); 2 #define bug(x) cout<<#x<<" is "<<x<<endl 3 #include <bits/stdc++.h> 4 #define iter ::iterator 5 using namespace std; 6 typedef long long ll; 7 typedef pair<int,ll>P; 8 #define pb push_back 9 #define mk make_pair 10 #define se second 11 #define fi first 12 #define rs o*2+1 13 #define ls o*2 14 const ll inf=1e18; 15 16 const int N=1e5+5; 17 18 int T; 19 20 int n,m; 21 22 double d[N]; 23 24 int main(){ 25 26 IO; 27 cin>>T; 28 cout.precision(2); 29 cout.setf(ios::fixed); 30 while(T--){ 31 cin>>n; 32 d[n]=0; 33 for(int i=n-1;i>=0;i--){ 34 d[i]=(double)n/(n-i)+d[i+1]; 35 } 36 37 cout<<d[0]<<endl; 38 } 39 40 41 42 }