啊?我是新犇犇。。帮帮忙。

P1035 [NOIP2002 普及组] 级数求和

撇鱼 @ 2017-09-28 13:29:33

错在哪呀。。

#include<bits/stdc++.h>
using namespace std;
int main()
{
        long double a=0.00000000000000000000000000000;
        int c=1;
        int k;
        cin>>k;
        do {
                c++;
                a=a+1.0/c;
           }while(a>k);
           cout<<c;
           return  0;
}

by miaojiexi @ 2017-09-28 13:44:34

#include<bits/stdc++.h>
using namespace std;
int main()
{
        long double a=0.00;
        int c=0;
        int k;
        cin>>k;
        do {
                c++;
                a=a+1.0/c;
           }while(a<=k); 
# //此处有一“犇犇(笨笨)”明明是while(a<=k)
           cout<<c;
           return  0;
}

by Npse_D @ 2017-09-28 15:16:28

神犇犇,犇犇,犇犇犇犇!!!


|