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
 
 
简单题
 #include<stdio.h>
int fact(int n)
{
int res=;
while(n>=)
{
res*=n;
n--;
}
return res;
}
int main()
{
printf("n e\n- -----------\n0 1\n1 2\n2 2.5\n3 2.666666667\n4 2.708333333\n");
int n,i;
double e;
for(n=;n<=;n++)
{
e=0.0;
for(i=;i<=n;i++)
{
e+=1.0/double(fact(i));
}
printf("%d %.9lf\n",n,e);
}
return ;
}

HDU 1008 u Calculate e的更多相关文章

  1. HDU 1012 u Calculate e【暴力打表,水】

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  2. HDU 1012 u Calculate e(简单阶乘计算)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Oth ...

  3. hdu 1012:u Calculate e(数学题,水题)

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. HDU 1008 电梯( 水题)

    题意: 电梯当前在0层,每在1层需要停5秒,往上走每层需6秒,往下走每层需要4秒. 思路: 在接收输入的时候直接计算了它,不用再弄一个循环.每计算一个请求就更新当前层,停留5秒的等到输出时再加上5*n ...

  5. hdu 1008 注意同层情况

    #include<iostream> using namespace std; int main() { int n; ]; while(cin>>n) { ,m=; ) br ...

  6. hdu 1008 Elevator

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description The hig ...

  7. hdu 1008

    题目意思是:给你N个数字  每个数字表示多少层楼  现在要你从0层楼开始坐电梯  一次按顺序走过这些楼层 规则是 上楼6秒 ,下楼4秒,每次到达一个楼层停5秒..... 思路:模拟 代码如下:(要注意 ...

  8. ACM hdu 1008 Elavator

    Elevator其实是一道水题,思路也很简单,但不知道怎么也不能AC,后来看了别人的再比较自己的以后找到错误. 在判断奇偶数之后的语句时,我用了if()  else if(),这是不能AC的原因,这种 ...

  9. HDU 1012 u Calculate e

    题解:直接模拟 #include <cstdio> int main(){ puts("n e");puts("- -----------");pu ...

随机推荐

  1. Linux install sogou input method

    # Copyright (c) 2016, 付刘伟 (Liuwei Fu)# All rights reserved.# 转载请注明出处 Linux下安装搜狗输入法需要安装以下插件,当以下所有插件安装 ...

  2. iOS Quartz2D画图

    对于刚接触Quartz2D的同学来说,先了解 上下文 的概念,再从最基础的画线来具体体验Quartz2D的画图步骤 介绍Quart2D :是苹果官方的二维(平面)绘图引擎,同时支持iOS和macOS系 ...

  3. Girl Develop It Chapter Leaders at 2015 Annual Leadership Summit

    Girl Develop It Chapter Leaders at 2015 Annual Leadership Summit Corinne Warnshuis, Executive Direct ...

  4. Linux的一些简单命令(二)

    1.查看防火墙状态:service iptables status 2.开启防火墙:service iptables start 3.关闭防火墙:service iptables stop 4.创建目 ...

  5. 照片处理软件(iSee图片专家) 3.930 中文免费版

    软件名称: 照片处理软件(iSee图片专家) 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 13.5MB 图片预览: 软件简介: iSee图片专家,免费一 ...

  6. easy-ui 有依赖关系的下拉列表(省市区县)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. Importing Product Images on Magento

    Multiple product images of each type can be imported into Magento, and associated with a specific pr ...

  8. 关于数据汇总方面返回Json数据的小小心得

    在一开始的开发中,计算好相关数据,然后通过 1.拼串 2.实例化Dictory对象再通过JavaScriptSerializer转换为json. 其中,2只适合于二维数据.1适合多维数据,但拼串比较费 ...

  9. centos7如何安装pandoc

    1 Install stack 1.1 Add the appropriate source repository: curl -sSL https://s3.amazonaws.com/downlo ...

  10. 修改LibreOffice Draw中定义的样式名称

    目前我使用的是LibreOffice 4.2.4.2.经过以往的测试和使用经验,这是诸多版本中较为稳定和bug相对较少的.今天无意中发现该版本的LibreOffice Draw存在一个问题:样式名称修 ...