HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e【水题】

来源:互联网 发布:smart forfour 知乎 编辑:程序博客网 时间:2024/05/19 02:44

u Calculate e
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 20144 Accepted: 11703 Special Judge

Description

A simple mathematical formula for e is 
e=Σ0<=i<=n1/i!

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

Input

No input

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 Input

no input

Sample Output

n e- -----------0 11 22 2.53 2.6666666674 2.708333333...

Source

Greater New York 2000

Regionals 2000 >> North America - Greater NY


问题链接:HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e

问题简述:(略)

问题分析:这是一个简单的计算问题,控制好循环并且注意格式就可以了。

程序说明:(略)

题记:(略)

 

AC的C语言程序如下

/* HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e */#include <stdio.h>#define N 9int main(void){    double e = 2.5, f=2.0;    int i;    printf("n e\n");    printf("- -----------\n");    printf("0 1\n");    printf("1 2\n");    printf("2 2.5\n");    for(i=3; i<=N; i++) {        f *= i;        e += 1.0 / f;        printf("%d %.9f\n", i, e);    }    return 0;}



原创粉丝点击