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 ...
随机推荐
- css - 所有的a标签设置为新窗口打开
前言 由于工作的需要,需要把某个页面下的所有a标签都设置为新开新窗口,即:<a href="XXX">增加target:<a href="XXX&quo ...
- Linux进程状态解析
引言 Linux是一个多用户,多任务的系统,可以同时运行多个用户的多个程序,就必然会产生很多的进程,而每个进程会有不同的状态. 在下文将对进程的R.S.D.T.Z.X 六种状态做个说明. PROCE ...
- Instantaneous Transference(强连通分量及其缩点)
http://poj.org/problem?id=3592 题意:给出一个n*m的矩阵,左上角代表起始点,每个格子都有一定价值的金矿,其中‘#’代表岩石不可达,‘*’代表时空门可以到达指定格子,求出 ...
- 0619-dedeCMS数据表
CMS的层级从前台分主要分为首页--栏目页--内容页,从后台分主要是四张表之间的关系: 1.模型表--dede_channeltype(顶级) 2.栏目表--dede_arctype 3.数据表:分为 ...
- iis 服务器而配置php运行环境
第一步 下载php 下载压缩包就可以了 第二步 解压缩php到某个目录,比如D:\php php目录里面有两个php.ini,一个是php.ini-dist,比较适合开发用:一个是php.ini-re ...
- 通过Oracle透明网关连接Sybase
Oracle公司提出的透明网关技术可用于实现与其他多种类型的数据库的互联,实现不同类型数据之间建立连接,方便于使用者进行查询.近日,在公司的某项目的实施过程中,开发人员需要访问Sybase数据库中的某 ...
- node的api
一. 1.url: 绝对URI http://user:pass@www.example.com:80/dir/index.html?uid=1#ch1 协议 登录信息 服务器地址 端口 文件路径 查 ...
- STL之string篇
常用代码整理: #include<iostream> #include<cstdio> #include<cstring> #include<string&g ...
- 在mac上快捷找到nodejs的安装路径
打开控制台输入 which node ,得到的输出结果就是node安装路径
- 整合springboot,angular2,可以前后台交互数据
改造了一下angular2官方文档中的hero项目,让其可以进行后台的交互, https://github.com/DACHUYIN 源码在上面...博客就不写了....