zoukankan      html  css  js  c++  java
  • 解题报告:hdu1012

    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
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    元组类型
    字符串类型
    列表类型
    python 循环
    python语句
    python运算符
    python1
    软件管理
    rpm yum
    LVM
  • 原文地址:https://www.cnblogs.com/pprp/p/7492060.html
Copyright © 2011-2022 走看看