poj 1517 u Calculate e
2016-03-18 11:15
381 查看
u Calculate e
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
Sample Output
Time Limit: 1000MS | Memory Limit: 10000K | |||
Total Submissions: 19465 | Accepted: 11362 | Special Judge |
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 ...
#include<stdio.h> #include<string.h> #include<cstdio> #include<string> #include<math.h> #include<algorithm> #define LL long long #define PI atan(1.0)*4 #define DD double #define MAX 2002000 #define mod 100 #define dian 1.000000011 #define INF 0x3f3f3f using namespace std; int main() { LL n,m,j,i,t,k; printf("n e\n"); printf("- -----------\n"); DD sum=0; printf("0 1\n"); for(i=1;i<=9;i++) { printf("%d ",i); DD ans=1; for(j=1;j<=i;j++) ans*=j; sum+=1/ans; printf("%.10g\n",sum+1); } return 0; }
相关文章推荐
- 做人底线7句话
- 详解Linux系统中的日期设定与date命令的用法
- 简述JavaScript提交表单的方式 (Using JavaScript Submit Form)
- PHP 二维数组实现SQL中的ORDER BY排序效果
- HDU 1233 还是畅通工程(MST裸题)
- Java finally语句到底是在return之前还是之后执行?
- Android 内存优化 (防Memory Leak)
- 【读书笔记】数据仓库工具箱 维度建模指南
- 浅谈Storm流式处理框架
- jenkins部署War包命令各JOB解析
- HTML--元素居中各种处理方法2
- PKCS 发布的15 个标准与X509
- 写给 iOS 开发者的 Hopper + lldb 简介
- STL(Standard Template Library)
- UDP的首部格式
- Android项目开发经验汇总
- rotate list
- 子线程,主线程
- 通过HttpModule管道,帮助api对接开发
- 建造者模式加模板模式实现建造小人 C++