JOE is on TV!(CF-1293B)

Problem Description

Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!

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 s(s>0) opponents remaining and t (0≤t≤s) of them make a mistake on it, JOE receives t/s dollars, and consequently there will be s−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 n (1≤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−4. In other words, if your answer is a and the jury answer is b, then it must hold that |a−b|max(1,b)≤10−4.

Examples

Input

1

Output

1.000000000000

Input

2

Output

1.500000000000

题意:Joe 和 n 个人进行知识竞赛,一旦答错一个题就会离场,现在假设 Joe 永远不会答错题,直到赛场上仅剩 Joe 结束比赛,对于每个问题来说,如果 Joe 有 s 个剩余的对手,他们之中的 t 个人答错了题,那么 Joe 会得到 t/s 元,同时下一个题对手数量变为 s-t,问比赛结束时,Joe 最大能获得多少奖励

思路:显而易见,每个问题只有一个人答错时,能获得最大的利益,因此题目本质是求 1+\frac{1}{2}+\frac{1}{3}+...+\frac{1}{n}

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
#define Pair pair<int,int>
LL quickPow(LL a,LL b){ LL res=1; while(b){if(b&1)res*=a; a*=a; b>>=1;} return res; }
LL multMod(LL a,LL b,LL mod){ a%=mod; b%=mod; LL res=0; while(b){if(b&1)res=(res+a)%mod; a=(a<<=1)%mod; b>>=1; } return res%mod;}
LL quickMultPowMod(LL a, LL b,LL mod){ LL res=1,k=a; while(b){if((b&1))res=multMod(res,k,mod)%mod; k=multMod(k,k,mod)%mod; b>>=1;} return res%mod;}
LL quickPowMod(LL a,LL b,LL mod){ LL res=1; while(b){if(b&1)res=(a*res)%mod; a=(a*a)%mod; b>>=1; } return res; }
LL getInv(LL a,LL mod){ return quickPowMod(a,mod-2,mod); }
LL GCD(LL x,LL y){ return !y?x:GCD(y,x%y); }
LL LCM(LL x,LL y){ return x/GCD(x,y)*y; }
const double EPS = 1E-6;
const int MOD = 1000000000+7;
const int N = 100000+5;
const int dx[] = {0,0,-1,1,1,-1,1,1};
const int dy[] = {1,-1,0,0,-1,1,-1,1};
using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    double sum = 0;
    double temp = (double)n;
    for (int i = 1; i <= n; i++) {
        sum += 1.0 / temp;
        temp--;
    }

    printf("%.4f\n", sum);

    return 0;
}

 

posted @ 2022-09-20 22:50  老程序员111  阅读(13)  评论(0)    收藏  举报