hdu_1012_u Calculate e_201310121519
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的更多相关文章
- [转] 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 ...
- 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 ...
- maven -- 问题解决(二)解决“Could not calculate build plan”问题
错误提示如下:(eclipse+maven) Could not calculate build plan: Failure to transfer org.apache.maven.plugins: ...
- 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function
Calculate the Function Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...
- hdu 1012:u Calculate e(数学题,水题)
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Calculate its MTBF assuming 2000 FITS for each DRAM
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A common unit of meas ...
- 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 ...
- 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 ...
- Calculate the formula
Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2. Input ...
随机推荐
- kubernetes Traefik ingress配置详解
理解Ingress 简单的说,ingress就是从kubernetes集群外访问集群的入口,将用户的URL请求转发到不同的service上.Ingress相当于nginx.apache等负载均衡方向代 ...
- Ruby 遍历多个数组
puts("----------------------------------------") puts(" 多重指定 test") ...
- roundabout旋转幻灯
jquery.roundabout.js文件/** * jQuery Roundabout - v2.4.2 * http://fredhq.com/projects/roundabout * * M ...
- codeforces——贪心
codeforces 804A Find Amir http://codeforces.com/problemset/problem/804/A /* 题意:给定n个学校,需要遍历所有学校,可从任 ...
- JavaScript中.和[]有什么区别?
.与[]都可以用于读取或修改对象属性. <script> var myData={ name:"Adam", weather:"sunny", }; ...
- ORA-01012:not logged on的解决办法
conn / as sysdba 报错ORA-01012: not logged on 发生原因:关闭数据库是shutdown 后面没有接关闭参数中的任何一个. nomal ————- —-所有连接都 ...
- Servlet访问路径的两种方式、Servlet生命周期特点、计算服务启动后的访问次数、Get请求、Post请求
Servlet访问路径的两种方式: 1:注解 即在Servlet里写一个@WebServlet @WebServlet("/myServlet") 2:配置web.xml < ...
- ClouderaManager与CDH
* ClouderaManager与CDH 集群简述 对于企业而言,一般的集群大小规模大概是如下映射关系: 集群大小 小:10~30节点 中:100~300节点 大:1000+节点 对应所需的zook ...
- windows下关闭进程树
关闭进程需要特定权限,如果你程序权限不够也会导致关闭进程失败.关闭进程树,需要遍历给定进程下的所有子进程,这个过程可以用并查集来做. 1.编写获取进程父进程的代码 #define ProcessBas ...
- nagios插件nagiosql安装配置
nagios插件nagiosql安装配置 # Nagiosql install [root@Cagios ~]# yum install -y libssh2 libssh-devel [root@C ...