码迷,mamicode.com
首页 > 其他好文 > 详细

解题报告:hdu1012

时间:2017-09-07 22:00:42      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:names   i++   font   date   erro   begin   size   uil   its   

2017-09-07 21:46:53

writer:pprp

写一下水题,调节一下心情~

/*
@theme: hdu 1012 u calculate e
@writer:pprp
@begin:21:31
@end:21:47
@error:前几个应该特别的输出
@date:2017/9/7
*/

#include <bits/stdc++.h>

using namespace std;
int dp[10];
void build()
{
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int i = 1; i < 10; i++)
    {
        dp[i] = dp[i-1] * i;
    }
}

int main()
{
    build();
//    for(int i = 0 ; i < 10 ;i++)
//    cout << dp[i] << endl;
    double ans;

    cout << "n e" << endl;
    cout << "- -----------" << endl;
    cout << "0 1" << endl;
    cout << "1 2" << endl;
    cout << "2 2.5" << endl;
    for(int i = 3 ; i < 10 ; i++)
    {
        ans = 0.0;
        for(int j = 0; j <= i; j++)
        {
            ans += 1.0/dp[j];
        }
        cout << i << " " ;
        printf("%.9lf\n",ans);
    }
    return 0;
}

 

解题报告:hdu1012

标签:names   i++   font   date   erro   begin   size   uil   its   

原文地址:http://www.cnblogs.com/pprp/p/7492060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!