求改正

P1035 [NOIP2002 普及组] 级数求和

瓜皮少年 @ 2017-09-26 13:46:54

#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main() {
    int k,n=0;
    float Sn=0.0000;
    cin>>k;
    do {
        n++;
        Sn=Sn+(1.0/n);
    }    while(k>=Sn);
        cout<<n;
    return 0;
}

by Ryuuko @ 2017-09-26 13:54:58

精度太低用double


|