hdu_1012(水题。。。不能再水)

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<cmath>
 5 using namespace std;
 6 long long mp[10];
 7 double ans[10];
 8 void init(){
 9     mp[0] = mp[1] = 1;
10     for(int i = 2; i <= 9; i++){
11         mp[i] = mp[i-1]*i;
12     }
13     ans[0] = 1.0;
14     ans[1] = 2.0;
15     ans[2] = 2.5;
16     for(int i = 3; i <= 9; i++){
17         ans[i] = ans[i-1]+1.0/mp[i];
18     }
19 }
20 int main()
21 {
22     init();
23     printf("n e
- -----------
");
24     printf("0 1
1 2
2 2.5
");
25     for(int i = 3; i <= 9; i++){
26         printf("%d %.9lf
",i,ans[i]);
27     }
28     return 0;
29 }
原文地址:https://www.cnblogs.com/shanyr/p/6658602.html