大佬们问一下这错哪儿了

P1035 [NOIP2002 普及组] 级数求和

zhou1066140793 @ 2019-10-30 17:05:10

#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    int n = 2 , k;
    double sum = 1.000000;

    scanf("%d" , &k);
    while(sum <= k){
        sum += 1.0 / n;
        n++;
    }
    printf("%d" , n);
}

by muyang_233 @ 2019-10-30 17:07:08

具体是怎么错的?


by Binary_Search_Tree @ 2019-10-30 17:08:36

样例都没过还交。。。

输出n-1


by zhou1066140793 @ 2019-10-30 17:13:04

@Binary_Search_Tree

。。3q


|