daonan @ 2021-10-10 22:04:47
#include<stdio.h>
int main()
{
int k;
int n;
double sum;
scanf("%d",&k);
for(n=1;n<=100000;++n)
{
sum+=(double)1/n;
if(sum>k)
{
goto end;
}
}
end:
printf("%d",n);
return 0;
}
by 戏子 @ 2021-10-13 20:51:41
当K取值15,N的值大于十万 以下是我的代码
##include<stdio.h>
int main()
{
int k;
int n;
double num;
num=0;
scanf("%d",&k);
for(n=0;num<=k;)
{
n++;
num=1.0/n+num;
}
printf("%d",n);
return 0;
}
by CSNKULGC @ 2022-01-17 17:21:16
范围太小了,我一直开到2000000过了