ACM--公式--HDOJ 1012--u Calculate e--水

HDOJ题目地址:传送门

u Calculate e

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

Total Submission(s): 41480    Accepted Submission(s): 18881

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
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<memory.h>
using namespace std;
int jiecheng(int m){
    if(m<=1)
        return 1;
    else
        return m*jiecheng(m-1);
}
int main(){
    printf("n e\n- -----------\n");
    for(int i=0;i<=9;i++){
        double result=0;
        for(int j=0;j<=i;j++){
            result+=(1.0/jiecheng(j));
        }
        if(i==0||i==1)
            printf("%d %.0lf\n",i,result);
        else if(i==2)
            printf("%d %.1lf\n",i,result);
        else
            printf("%d %.9lf\n",i,result);
    }
}
时间: 2024-11-06 04:08:04

ACM--公式--HDOJ 1012--u Calculate e--水的相关文章

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 Problem Description A simple mathematical formula for e is where n is allowed to go to infini

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

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit

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

传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 52607    Accepted Submission(s): 24106 Problem Description A simple mathematical

poj 1517 &amp; hdu 1012 u Calculate e(简单阶乘)

POJ链接 :http://poj.org/problem?id=1517 HDU链接:http://acm.hdu.edu.cn/showproblem.php?pid=1012 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 o

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

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46844    Accepted Submission(s): 21489 Problem Description A simple mathematical formula for e is where n is allowed to go to infini

水题/hdu 1012 u Calculate e

题意 求n=0~9时的sigma(1/n!) 分析 因为刚学c++ 所以对浮点操作还是很不熟练,正好来了这么一道题 Accepted Code 1 /* 2 PROBLEM:hdu 1012 3 AUTHER:Nicole Lam 4 MEMO:水题 5 */ 6 #include<iostream> 7 #include<iomanip> 8 using namespace std; 9 double a[10]; 10 int main() 11 { 12 cout<&l

HDU 1012.u Calculate e【水】【8月16】

u Calculate e 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 generat

HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,Java就是打表,都不能AC,因为Java的输入是流,需要的时间比C真的长好多.... Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+ n ^2. Input In each

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of

HDOJ 1012

水题天天有,今天特别多....嘿嘿u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19289 Accepted Submission(s): 8423 Problem Description A simple mathematical formula for e is where n is allowed to g