Luo Gu P1035 Summation

Title Description

Known: of Sn =. 1. 1 + / 2 +. 1 /. 3. 1 + ... + / n- . Clearly for any integer K , when n is large enough, of Sn is greater than K .

Are now given an integer K ( 1≤k≤15 ), requires a minimum of the calculated n- ; that of Sn> K .

Input Format

A positive integer K

Output Format

A positive integer N

Sample input and output

Input # 1
1
Output # 1
2
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int k,i=0;
 6     double s=0.0000;
 7     cin>>k;
 8     do
 9     {
10         i++;
11         s=s+ (1.0/i);
12     } while (s<=k);
13     cout<<i;
14     return 0;
15 }

 

Guess you like

Origin www.cnblogs.com/anbujingying/p/11293661.html