求助 这样输出来只有20分

P1035 [NOIP2002 普及组] 级数求和

wei060925 @ 2024-11-27 22:21:58

#include<stdio.h>
int main()
{
   int k;
   scanf("%d",&k);
   int n=1;
   double sum=0,a;
   do
   {
       a=1.0/n;
       sum+=a;
       n++;
   }while(sum<k);
   printf("%d",n);
}

by WJnY @ 2024-11-27 22:30:51

const double EPS = 1e-5;
............
do{
}while(sum-EPS<k);
print("%d",n-1);

@wei060925


by RICK123456 @ 2024-12-03 19:07:05

tyuytuytutuytuytuytuytuytuytuytuy


|