求大佬啊,给个代码吧

P1035 [NOIP2002 普及组] 级数求和

陈情魏无羡 @ 2019-12-17 20:52:56

没什么好说的,直接给代码吧(别问我为什么不抄题解)


by 4SunnyH @ 2019-12-17 20:55:45

???


by 友利奈緒 @ 2019-12-17 21:11:31

???


by 开始新的记忆 @ 2019-12-17 21:15:22

???


by Lithium_Chestnut @ 2019-12-17 21:26:05

???


by 吴勉之 @ 2019-12-17 21:32:12

?????????????????????


by lhd2006 @ 2019-12-17 23:03:55

@LXZCYAN 真巧,我今天才做这道题

#include <iostream>
using namespace std;
int main()
{
    int n,ans;
    double sum=0;
    cin>>n;
    for(int i=1;;i++){
        sum+=(double)1/i;
        if(sum>n){ans=i;break;}
    }
    cout<<ans<<endl;
    return 0;
}

by 陈情魏无羡 @ 2019-12-18 18:53:11

@lhd2006 膜拜大佬


by lhd2006 @ 2019-12-18 22:21:44

@LXZCYAN 都是灰名,何必呢


|