hdu 1012 u Calculate e
来源:互联网 发布:男士 长袖 知乎 编辑:程序博客网 时间:2024/06/09 22:47
u Calculate e
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45773 Accepted Submission(s): 21027
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.
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 11 22 2.53 2.6666666674 2.708333333题目解析:这个题的意思就是让你输出n从0到9公式求出的值,是一个非常简单的题,但是要注意输出。代码:#include<iostream>#include<cstdio>using namespace std;int main(){ int i,j,jiecheng[10]; double a[10]; cout<<"n e"<<endl<<"- -----------"<<endl; for(i=0; i<=9; i++) { for(j=0; j<i; j++) { jiecheng[0]=1; jiecheng[i]=i*jiecheng[i-1]; } a[0]=1; a[i]=a[i-1]+1.0/jiecheng[i]; if(i==0) cout<<"0"<<" "<<"1"<<endl; if(i==1) cout<<"1"<<" "<<"2"<<endl; if(i==2) cout<<"2"<<" "<<"2.5"<<endl; if(i>=3) { cout<<i<<" "; printf("%.9lf\n",a[i]); } } return 0;}
0 0
- HDU 1012 u Calculate e
- HDU 1012 u Calculate e
- HDU 1012 u Calculate e
- HDU--1012--u Calculate e
- hdu 1012 u Calculate e
- HDU 1012 u Calculate e
- hdu 1012 u Calculate e
- u Calculate e hdu 1012
- hdu 1012 u Calculate e
- hdu-1012-u Calculate e
- hdu 1012 u Calculate e
- hdu 1012 u Calculate e
- HDU 1012u Calculate e
- hdu 1012 u Calculate e
- hdu 1012 u Calculate e
- HDU 1012 u Calculate e
- hdu 1012 u Calculate e
- HDU 1012 u Calculate e
- 安装TA-LIB
- MySQL数据库
- boost noncopyable实现与ADL
- SpringMvc下实现delete和put请求
- 融资前和投资人的一次讨论
- hdu 1012 u Calculate e
- 几个适合学习虚幻4的社区和帖子
- 【模拟】洛谷 P1097 统计数字
- 使用MultiValueMap巧妙解决拼字符串问题
- 使用Eclipse RCP进行桌面程序开发(一):快速起步
- 3D数学基础 图形与游戏开发的学习 第四章 向量
- 数据库 事务
- 什么是机器学习?
- scikit-learn 文本挖掘概念