TLE 要怎么改--

P1035 [NOIP2002 普及组] 级数求和

hana999 @ 2020-02-02 15:37:59

超时了

#include<stdio.h>
main()
{
    int i,k,Sn=1;
    scanf("%d",&k);
    for(i=2;;i++)
    {
        Sn=Sn+1/i;
        if(Sn>k)
        break;
    }
    printf("%d",i);
    return 0;
}

by ljm001 @ 2020-02-06 10:01:59

用while()


by ljm001 @ 2020-02-06 10:03:20

其实也错


上一页 |