HDU 1012 u Calculate e

题解:直接模拟

#include <cstdio>
int main(){  
    puts("n e");puts("- -----------");puts("0 1");  
    double ans=1.0,f=1.0;  
    for(int i=1;i<=9;i++){
        if(i==1)printf("%d %.0lf\n",i,(ans+=(f/=(double)i)));
        else if(i==2)printf("%d %.1lf\n",i,(ans+=(f/=(double)i)));
        else printf("%d %.9lf\n",i,(ans+=(f/=(double)i)));  
    }return 0;  
}  
posted @ 2014-08-29 17:40  forever97  阅读(105)  评论(0编辑  收藏  举报