蒟蒻求助!!

P1035 [NOIP2002 普及组] 级数求和

2110liuhaolin19 @ 2022-09-23 20:49:13

蒟蒻求助!!


by Vanishing_Stars @ 2022-09-23 20:54:26

@2110liuhaolin19 这题很简单的,跟你说下思路吧:先是输入一个k,之后用for循环来循环一下,n每次+=1/n就行,每次循环都判断一下n是不是大于k了,一大于就结束程序并输出


by Katz @ 2022-09-23 20:55:31

题解不是用来看的.jpg


by 2110liuhaolin19 @ 2022-09-23 21:06:03

谢谢各位大佬 !!!


by Gmzhgmzh @ 2022-10-03 18:10:24

#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,n=0;
scanf("%d",&k);
for(double s=0;s<=k;++n,s+=1.0/n);
printf("%d",n);
return 0;
}

送给你


|