u Calculate e
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 25494    Accepted Submission(s): 11312

Problem Description
A simple mathematical formula for e is

where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.

Output
Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.

Sample Output
n e
- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333

Source
Greater New York 2000

Recommend
JGShining

#include <stdio.h>

int jc(int n)
{
    int i,sum=1;
    if(n==0)
    return 1;
    if(n>0)
    {
        for(i=1;i<=n;i++)
        sum*=i;
        return sum;
    }
}

int main()
{
    int i,j,e,t,n=9;
    double sum=0;
    printf("n e\n");
    printf("- -----------\n");
    printf("0 1\n");
    printf("1 2\n");
    printf("2 2.5\n");
    for(j=3;j<=n;j++)
    {
        sum=0;
        for(i=0;i<=j;i++)
        {
            t=jc(i);
            sum+=1.0/t;
        }
        printf("%d %.9lf\n",j,sum);
    }
    return 0;
}

hdu_1012_u Calculate e_201310121519的更多相关文章

  1. [转] PHP计算两个坐标之间的距离, Calculate the Distance Between Two Points in PHP

    Calculate the Distance Between Two Points in PHP There are a lot of applications where it is useful ...

  2. CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved

    CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin ...

  3. maven -- 问题解决(二)解决“Could not calculate build plan”问题

    错误提示如下:(eclipse+maven) Could not calculate build plan: Failure to transfer org.apache.maven.plugins: ...

  4. 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function

    Calculate the Function Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...

  5. hdu 1012:u Calculate e(数学题,水题)

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. Calculate its MTBF assuming 2000 FITS for each DRAM

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A common unit of meas ...

  7. u Calculate e 分类: HDU 2015-06-19 22:18 14人阅读 评论(0) 收藏

    u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  8. How to calculate a good InnoDB log file size

    Peter wrote a post a while ago about choosing a good InnoDB log file size.  Not to pick on Peter, b ...

  9. Calculate the formula

    Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input ...

随机推荐

  1. bzoj1089 [SCOI2003]严格n元树(dp+高精)

    1089: [SCOI2003]严格n元树 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1899  Solved: 954[Submit][Statu ...

  2. [App Store Connect帮助]二、 添加、编辑和删除用户(3)添加和编辑用户

    您可以在“用户和访问”中添加和编辑用户. 如果您以个人名义在“Apple 开发者计划”注册,您可以授权用户访问您 App Store Connect 中的内容.所有用户只拥有 App Store Co ...

  3. 如何解决error LNK2001(转载)

    转自:http://www.cnblogs.com/myzhijie/articles/1658545.html 解决外部符号错误:_main,_WinMain@16,__beginthreadex ...

  4. Codeforces Round 411 Div.2 题解

    A Fake NP standard input/output s, MB Submit Add to favourites x3673 B -palindrome standard input/ou ...

  5. IIS 配置 SVC

    IIS8中添加WCF支持几种方法小结[图文] 方法一 最近在做Silverlight,Windows Phone应用移植到Windows 8平台,在IIS8中测试一些传统WCF服务应用,发现IIS8不 ...

  6. Github提交本地版本是遇到的问题

    问题如下:*** Please tell me who you are. Run git config --global user.email "you@example.com" ...

  7. Windows系统文件名的最大长度

    1.文件名的最大长度 Windows 通常限定文件名最多包含 260 个字符.但实际的文件名必须少于这一数值,因为完整路径(如 C:\Program Files\filename.txt)都包含在此字 ...

  8. SQL基本操作——通配符

    SQL 通配符:在搜索数据库中的数据时,SQL 通配符可以替代一个或多个字符.SQL 通配符必须与 LIKE 运算符一起使用.在 SQL 中,可使用以下通配符: 通配符 描述 % 替代一个或多个字符 ...

  9. SQL基本操作——日期函数

    SQL日期:当我们处理日期时,最难的任务恐怕是确保所插入的日期的格式,与数据库中日期列的格式相匹配.只要数据包含的只是日期部分,运行查询就不会出问题.但是,如果涉及时间,情况就有点复杂了.在讨论日期查 ...

  10. 【技术累积】【点】【java】【29】MapUtils

    内容 是Apache组织下的commons-collections包中的工具类 <dependency> <groupId>commons-collections</gr ...