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

u Calculate e


Time Limit: 2000/1000 MS
(Java/Others)    Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s): 28686    Accepted
Submission(s): 12762

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   |   We have
carefully selected several similar problems for you:  1020 1014 1019 1032 1037 


  水题

  切一道水题,放松下心情。

  这道题没有输入,只有输出。

  前3组数据由于输出格式不统一,直接输出即可。后面的数可用迭代思路求得,不用从头重新计算了。

  代码:


 1 #include <stdio.h>
2 int main()
3 {
4 int i;
5 printf("n e\n");
6 printf("- -----------\n");
7 printf("0 1\n"); //没有统一格式,提前输出。
8 printf("1 2\n");
9 printf("2 2.5\n");
10 double ans = 1;
11 double t = 1;
12 for(i=1;i<=9;i++){
13 t = 1.0/i*t; //迭代计算
14 ans += t;
15 if(i<3) continue;
16 printf("%d %.9lf\n",i,ans);
17 }
18 return 0;
19 }

hdu 1012:u Calculate e(数学题,水题),布布扣,bubuko.com

时间: 2024-10-11 19:14:34

hdu 1012:u Calculate e(数学题,水题)的相关文章

HDU 1012.u Calculate e【水】【8月16】

u Calculate e 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 generat

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结

HDU 4007 Dave (基本算法-水题)

Dave Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there

HDU 1520 Anniversary party 树DP水题

非常水的树DP,状态为当前为i,上级来没来 然后跑一遍记忆化搜索即可 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdlib>

poj 1517 &amp; hdu 1012 u Calculate e(简单阶乘)

POJ链接 :http://poj.org/problem?id=1517 HDU链接:http://acm.hdu.edu.cn/showproblem.php?pid=1012 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 o

HDU 4022 Bombing(基本算法-水题)

Bombing Problem Description It's a cruel war which killed millions of people and ruined series of cities. In order to stop it, let's bomb the opponent's base. It seems not to be a hard work in circumstances of street battles, however, you'll be encou

HDU 5344 MZL&#39;s xor(水题)

MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 456    Accepted Submission(s): 322 Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to

hdu 4274 Spy&#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the