codeforces 1293B JOE is on TV!

B. JOE is on TV!

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
3R2 - Standby for Action
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

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 1/2+1/1=1.5 dollars.

题意:

某某人打败所有对手能够获得最大美金是多少,每一轮得到的钱是t/s个,t是本轮失败的人数,s是本轮需要打败的总人数。

思路:

因为当s>=2时,2/s < 1/s+1/(s-1),同理每一轮战胜一个人的情况时获得美金最多的一种情况了。

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    double cnt = 0;
    for (int i = n; i >= 1; i--) {
        double x = i * 1.0;
        cnt += 1.0 / x;
    }
    printf("%.12lf", cnt);
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值