样例能够

P1035 [NOIP2002 普及组] 级数求和

Lvyuze @ 2021-08-08 20:11:14

#include<iostream>
using namespace std;
int k,n,s;
int main()
{
cin>>k;
for(n=2;s>=k;n++){
    s=s+1/n;
}
cout<<n<<endl;
return 0;
}

by 一SakuRa @ 2021-08-08 20:16:04

@Lvyuze

#include<bits/stdc++.h>
using namespace std;
int k,n;
int main(){
    cin>>k;
    for(register double i=0;i<=k;n++,i+=1.0/n);
    cout<<n;
}

by Lvyuze @ 2021-08-08 20:37:47

@一SakuRa 过了,谢谢大佬


by 一SakuRa @ 2021-08-08 20:46:50

@Lvyuze

阿这我是个初一蒟蒻qwq


|