black_lu @ 2023-11-12 15:47:12
------------
#include <stdio.h>
int main()
{
int num=1;
int k;
int n=1;
double S=0.0;
scanf("%d",&k);
while(int(S)<=k)
{
S=S+(1/n)+(1/n+1);
n+=2;
num++;
}
printf("%d",num*2);
return 0;
}
#include <stdio.h>
<p>
int main()
{
int num=1;
int k;
int n=1;
double S=0.0;
scanf("%d",&k);
while(int(S)<=k)
{
S=S+(1/n)+(1/n+1);
n+=2;
num++;
}
printf("%d",num*2);
return 0;
}
by black_lu @ 2023-11-12 15:48:00
求大佬们看看是哪里错了,一直WA
by Carl170679 @ 2023-11-12 15:54:01
@black_lu 我给你改了两下
by Carl170679 @ 2023-11-12 15:57:22
#include <stdio.h>
int main()
{
int num=1;
int k;
int n=1;
double S=0.0;
scanf("%d",&k);
while((int)S<=k)
{
S=S+(1.0/n)+(1.0/(n+1));
n+=2;
num++;
}
printf("%d\n",num*2);
return 0;
}
by Lin_AMAMK @ 2023-11-12 16:06:26
**这是我的代码。可以看一下
https://www.luogu.com.cn/paste/0g33c0uq
by black_lu @ 2023-11-12 16:52:28
@Carl0626 谢谢大佬┭┮﹏┭┮,但是这边还是WA,是不是我的逻辑搞错了啊
by black_lu @ 2023-11-12 16:54:07
@Lin_AMAMK 好的好的好的,谢谢大佬