求帮忙 没找出来哪儿写错了

P1035 [NOIP2002 普及组] 级数求和

朱桂濡 @ 2017-10-04 14:38:41

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

by d3NtMDAw @ 2017-10-04 14:57:39

#include <stdio.h>
int main()
{
    long double Sn=0,p=0;
    int k,n=1;
    scanf("%d",&k);
    while(Sn<=k)
    {
        p=1.0/n;
        Sn+=p;
        n++;
    }
    printf("%d",n-1);
    return 0;
}

|