hdoj 1012 u Calculate e
u Calculate e
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 37350 Accepted Submission(s):
16905
where n is allowed to go to infinity.
This can actually yield very accurate approximations of e using relatively small
values of n.
formula for the values of n from 0 to 9. The beginning of your output should
appear similar to that shown below.
#include<stdio.h>
#include<string.h>
double b[20];
double fun(int x)
{
int i;
double sum=1.0,a=1.0;
for(i=1;i<=x;i++)
{
sum=a*sum;
a=a+1;
}
sum=1/sum;
return sum;
}
int main()
{
int n,m,j,i;
double sum=0;
b[0]=1;b[1]=1;
for(i=2;i<=9;i++)
b[i]=fun(i);
printf("n e\n");
printf("- -----------\n");
for(i=0;i<=9;i++)
{
printf("%d ",i);
sum+=b[i];
if(i==2)
{
printf("2.5\n");
continue;
}
if(sum==(int)(sum))
printf("%d\n",(int)(sum));
else
printf("%.9lf\n",sum);
}
return 0;
}
hdoj 1012 u Calculate e的更多相关文章
- HDU 1012 u Calculate e(简单阶乘计算)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Oth ...
- HDU 1012 u Calculate e【暴力打表,水】
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 1012:u Calculate e(数学题,水题)
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- ACM YTU 1012 u Calculate e
u Calculate e Problem Description A simple mathematical formula for e is where n is allowed to go to ...
- HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...
- 杭电 1012 u Calculate e【算阶乘】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1012 解题思路:对阶乘递归求和 反思:前面3个的输出格式需要注意,可以自己单独打印出来,也可以在for ...
- HDU 1012 u Calculate e
题解:直接模拟 #include <cstdio> int main(){ puts("n e");puts("- -----------");pu ...
- 1012 u Calculate e
A simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield ...
- Problem : 1012 ( u Calculate e )
/*tips:本题只有输入,没有输出,在线测试只检测结果,所以将前面几个结果罗列出来就OK了.为了格式输出问题纠结了半天,最后答案竟然还是错的....所以啊,做题还是得灵活变通.*/ #include ...
随机推荐
- bug - colorWithPatternImage:
// 在ios5之前, 再通过以下方法设置背景时, 有闪屏bug self.view.backgroundColor = [UIColor colorWithPatternImage:<#(no ...
- ios更改UITabBarController背景以及选中背景图片的方法
一.背景图片 1.5.0以上版本 UIImage *image = [UIImage imageNamed:@"system_tabbar_bg.png"]; [ ...
- SQL中not and or优先级问题
SQL中 not and or优先级问题 刚刚在项目中遇到这样一个问题,SQL语句如下: 我想要的结果的条件是:1. LIBRARY_ID=1 或者 LIB_ID=1 2.STATUS=3 但是结果 ...
- Hbase region 某个regionserver挂掉后的处理
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwoAAACdCAMAAAAjbX91AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK
- underscore vs jquery
http://wordpress.tv/2013/06/23/k-adam-white-underscore-and-backbone-jquerys-new-friends/ http://www. ...
- JavaSE replaceAll 方法
private String srcStr = "index\\.php\\?action=";//要替换的原字符串 private String destStr = " ...
- POJ - 1523 SPF
题目要求割顶集,并且还要求出去掉割顶之后剩下的图连通数目. tarjan算法求出割顶后直接枚举就可以了吧. 一开始想到利用iscut[u]的次数也就是点u被判定为割顶的次数求连通分量数,还有利用与结点 ...
- Java缓存--JCS
添加外部包: jcs-1.3.jar concurrent-10.3.jar cache.cff # optional region "myCache" specific conf ...
- C#中使用正则表达式提取超链接地址的集中方法(转)
一般在做爬虫或者CMS的时候经常需要提取 href链接或者是src地址.此时可以使用正则表达式轻松完成. Regex reg = new Regex(@"(?is)<a[^>]* ...
- cocos2d-html5 Layer 和 Scene 创建模式
var myLayer = cc.Layer.extend({ init:function() {//2 界面 var bRet = false; if (this._super()) { bRet ...