博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
joj1020
阅读量:4316 次
发布时间:2019-06-06

本文共 1193 字,大约阅读时间需要 3 分钟。

: u Calculate e


Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
3s 8192K 6098 1521 Standard

Background

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 11 22 2.53 2.6666666674 2.708333333
#include
double factoral(double); double showsum(int ); int main(void) {
int n, i; double sum = 0; printf("n e\n"); printf("- -----------\n"); printf("0 1\n"); printf("1 2\n"); printf("2 2.5\n"); for (i=3; i<=9; i++) {
printf("%d ", i); printf("%.9lf\n",1+showsum(i)); } return 0; } double factoral(double i) {
if (i == 0) return 1; else return i*factoral(i-1); } double showsum(int n) { double sum=0; for(int i=1;i<=n;i++) {
sum+=(double)1/factoral(i); } return sum; }

 


This problem is used for contest:


/ / /

转载于:https://www.cnblogs.com/RootJie/archive/2011/11/02/2233432.html

你可能感兴趣的文章
CSS3 transform制作的漂亮的滚动式导航
查看>>
《小强升职记——时间管理故事书》读书笔记
查看>>
Alpha 冲刺(3/10)
查看>>
Kaldi中的Chain模型
查看>>
spring中的ResourceBundleMessageSource使用和测试示例
查看>>
css规范 - bem
查看>>
UVALive 6145 Version Controlled IDE(可持久化treap、rope)
查看>>
mysql 将两个有主键的表合并到一起
查看>>
底部导航栏-----FragmentTabHost
查看>>
在linux中安装jdk以及tomcat并shell脚本关闭启动的进程
查看>>
apk,task,android:process与android:sharedUserId的区别
查看>>
前端实现文件的断点续传
查看>>
转:spring4.0之二:@Configuration的使用
查看>>
【Android开发】交互界面布局详解
查看>>
状态机编程思想(1):括号内外字符串统计
查看>>
K-Means聚类和EM算法复习总结
查看>>
[转]Bat脚本处理ftp超强案例解说
查看>>
P3901 数列找不同
查看>>
利用无线网络数据包分析无线网络安全
查看>>
MEMBER REPORT
查看>>