首页 > 其他 > 详细

FZU1058

时间:2015-04-07 00:38:53      阅读:287      评论:0      收藏:0      [点我收藏+]

其实这里主要就是long double的使用

因为用printf不怎么好输出,所以最好用cout输出

传送门:http://acm.fzu.edu.cn/problem.php?pid=1058

 

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef long double LDB;

int main(){
    int n;
    while(~scanf("%d",&n)){
        LDB ans=0;
        for(int i=1;i<=n;i++){
            ans+=(LDB)1/i;
        }
        cout<<fixed<<setprecision(12)<<ans<<endl;
    }
    return 0;
}

 

FZU1058

原文:http://www.cnblogs.com/csust-qwb/p/4397229.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!