No!

P1035 [NOIP2002 普及组] 级数求和

Giant_Breast @ 2022-07-02 12:54:11

#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,c=2,d=1;
    double b=1;
    cin>>a;
    while(1){
        b=b+1/c;
        c++;
        d++;
        if(a>=b){
            break;
        }
    }
    cout<<d;
    return 0;
}

by wtcqwq @ 2022-07-02 12:57:58

标题非得这么魔怔么?


by Giant_Breast @ 2022-07-02 13:01:55

@World_Trade_Center 为什么会错? 还是0分


by Untitled10032 @ 2022-07-02 13:11:51

#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,d=1;
    double b=1, c=2;
    cin>>a;
    while(1){
        b=b+1/c;    //若c为int,则1/c为int,永远是0
        c++;
        d++;
        if(a<b){    //原: a>=b
            break;
        }
    }
    cout<<d;
    return 0;
}

by _DX3906_ @ 2022-07-02 13:43:40


by dingshengyang @ 2022-07-15 13:22:04


|