博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ACM HDU 1012 u Calculate e
阅读量:6935 次
发布时间:2019-06-27

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

u Calculate e

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 19296 Accepted Submission(s): 8425

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
 
Recommend
JGShining
 
 
#include
#include
double run(int n){ if(n == 0 || n == 1) return 1; else return run(n-1)*n;}int main(){ int n, i, j; double sum[11]; memset(sum, 0, sizeof(sum)); printf("n e\n- -----------\n0 1\n1 2\n2 2.5\n"); sum[2] = 2.5; for(i=3; i<=9; i++) { sum[i] = sum[i-1] + 1.0/run(i); printf("%d %.9lf\n", i, sum[i]); }}

结题报告:

WA的情况并没有那么唯一的,捉襟见肘的感觉很难见到AC的那一刻,做题需要严谨和耐心,WA多次没问题,挣扎成长只是暂时

如果没有这个提示,我想我会再禁锢一段时间

n e

- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
5 2.716666667
6 2.718055556
7 2.718253968
8 2.718278770
9 2.718281526
这是AC的数据,注意n=8的情况,最后面无意义的0还是要保留。所以n=0、1、2作为特殊值输出,剩下的用%.9lf即可,%.10lg就要WA了。

转载于:https://www.cnblogs.com/liaoguifa/archive/2012/09/23/2699098.html

你可能感兴趣的文章
AVFoundation学习Demo--拍摄视频
查看>>
阿里云账号注册流程方法(图文教程)
查看>>
亮道智能发布自动驾驶环境感知系统测试验证服务|2019 上海车展 ...
查看>>
ROS_机器人urdf建模仿真实践
查看>>
一碗鸡汤
查看>>
平台篇-58 HBase 平台实践和应用
查看>>
史上最大的实体关系抽取数据集!清华大学自然语言处理团队发布 FewRel ...
查看>>
K8s 1.14 发布了,Release Note 该怎么读?
查看>>
购买阿里云服务器,先试试主机免费试用能抢到不
查看>>
2018-01-11 Antlr4实现数学四则运算
查看>>
Docker 和 Kubernetes 从听过到略懂:给程序员的旋风教程
查看>>
ES6 模块加载export 、import、export default 、import() 语法与区别,笔记总结
查看>>
8Manage:如何变革性的加强企业采购管理?
查看>>
【Python3爬虫】常见反爬虫措施及解决办法(三)
查看>>
开源APM监控Pinpoint的快速部署和使用
查看>>
基于hi-nginx的web开发(python篇)——路由装饰器
查看>>
python设计模式(三):原型模式—快速实例化类的一种途径
查看>>
windows系统中,在当前目录下打开cmd命令行的两种方法
查看>>
IT外包,网络维护
查看>>
责任链设计模式
查看>>