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

P1035 [NOIP2002 普及组] 级数求和

撇鱼 @ 2017-09-28 13:27:20

错在哪呀。。

#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 lijianyangyf @ 2017-09-28 13:41:32

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
int k,t;double ans;
int main()
{
    ans=1.0;
    t=1;
    scanf("%d",&k);
    while(k>=ans)
    {
        t++;
        ans+=1.0/t;
    }
    printf("%d",t);
}
#真是“笨笨”

by lijianyangyf @ 2017-09-28 13:42:25

c--啊

笨笨


by miaojiexi @ 2017-09-28 13:46:08

#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); 
           cout<<c;
           return  0;
}

此处有一“犇犇(笨笨)”明明是while(a<=k)

跟帖+1


by liz525 @ 2017-10-02 13:14:01

a<=k


|