Title DescriptionDescription known: sn= 1+1/2+1/3+ ... +1/n. Obviously for any one integer k, when n is large enough, SN is greater than K.
An integer k (1<=k<=15) is given, which requires the calculation of a minimum n, which makes the sn>k.
input/output format input/output
Input Format:
A positive integer k.
output Format:
A positive integer n.
input and Output sample sample Input/output
sample Test point # #
Input Sample:1
Sample output:
2
idea: loop to explode, add a score each time, and then determine whether the SN is greater than k, greater than the output, or continue to cycle.
The code is as follows:
1#include <stdio.h>2 intMain ()3 { 4 intA; 5 Doubleb=0; 6 floati; 7scanf"%d",&a); 8 for(i=1; i<=1000000; i++) 9 { Tenb=b+1/I;//add one score at a time One if(B>a)//Meet the A { -printf"%.0lf\n", i); - return 0; the } - } - return 0; -}
Noip2002-Universal Group Rematch-second question-series summation