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\n- -----------\n");
24     printf("0 1\n1 2\n2 2.5\n");
25     for(int i = 3; i <= 9; i++){
26         printf("%d %.9lf\n",i,ans[i]);
27     }
28     return 0;
29 }

 

posted on 2017-04-02 11:21  若流芳千古  阅读(156)  评论(0编辑  收藏  举报

导航