求指出错误

P1035 [NOIP2002 普及组] 级数求和

谎言君_liar @ 2017-10-22 14:13:22

#include<bits/stdc++.h>
using namespace std;
int main(){
    double k,p=0;
    int n;
    cin>>k;
    for(double i=1;i<=10000000;i++){
        n++;
        p+=1.00000000/i;
        if(p>k){cout<<n;break;
        }
    }
}

by rts_GOD @ 2017-10-22 22:43:19

int n后面加个=0就行了


|