Codeforces Round #614 (Div. 2) B. JOE is on TV!

6367 단어
원제: Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs.nn"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are ss (s>0s>0) opponents remaining and tt (0≤t≤s0≤t≤s) of them make a mistake on it, JOE receives tsts dollars, and consequently there will be s−ts−t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input The first and single line contains a single integer nn (1≤n≤1051≤n≤105), denoting the number of JOE’s opponents in the show.
Output Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it’s absolute or relative error won’t exceed 10−410−4. In other words, if your answer is aa and the jury answer is bb, then it must hold that |a−b|max(1,b)≤10−4|a−b|max(1,b)≤10−4.
Examples inputCopy 1 outputCopy 1.000000000000 inputCopy 2 outputCopy 1.500000000000 Note In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be 12+11=1.512+11=1.5 dollars. 제목: 물문제야!아무리 생각해도 레벨이 맞아!1+1/2+1/3+1/4+...+1/n 하지만 수학의 근사 공식에 대해서는 안 해도 돼요. 재미없어요. 이 문제는 아무렇게나 해도 돼요!
#include
#include
#include
#include
#include
#include
#include
#include
#include 
#include
#include
#include
#include 
#include
using namespace std;	
int main()
{
	int t,k,t1,n1,a,b,c,d,e,f,n,m;	
	double x,ret;
	double sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		sum += 1.0/(i+1);
	}
	printf("%6lf", sum);
	return 0;
}

좋은 웹페이지 즐겨찾기