您的位置:首页 > 其它

HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e【水题】

2017-11-14 05:44 495 查看
u Calculate e

Time Limit: 1000MS Memory Limit: 10000K
Total 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 1
1 2
2 2.5
3 2.666666667
4 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 9

int 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: