当前位置:网站首页>Codeforces Round #614 (Div. 2) B. JOE is on TV!
Codeforces Round #614 (Div. 2) B. JOE is on TV!
2022-07-28 10:32:00 【Xiaoliu xuezha】
time limit per test: 1 second
memory limit per test: 256 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≤10^5),
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.
#include <iostream>
using namespace std;
int main()
{
int n;
double sum=0;
cin>>n;
for(int i=n;i>0;i--)
{
sum+=(1.0/i);
}
printf("%.12lf\n",sum);
return 0;
}
边栏推荐
- 华为入股石墨烯材料厂商富烯科技,持股10%
- CentOS7下安装mysql5.7
- 11、链表反转
- SuperMap iServer发布管理以及调用地图服务
- MySQL的SQL TRACE一例
- 上下文变量值(context values)陷阱及在 Go 中如何避免或缓和这些陷阱
- AP Autosar平台设计 1-2 导言、技术范围与方法
- 7. Dichotomy -- find a set of repeated or ordered but rotating arrays
- Database security - create login user + configure permissions [notes]
- ACM winter vacation training 7
猜你喜欢

gcc: error trying to exec 'as': execvp: No such file or directory

Idea packages jar packages and runs jar package commands

5. Dynamic programming -- Fibonacci series

Aqua Data Studio 18.5.0导出insert语句

机器学习--手写英文字母1--分类流程

初识SuperMap iDesktop

ACM winter vacation training 5

11. Linked list inversion

django-celery-redis异步发邮件

机器学习--手写英文字母2--导入与处理数据
随机推荐
阿里云镜像地址
管道、管程、管态的区别
Lucene 查询语法备忘
CentOS7下安装mysql5.7
Detailed explanation of super complete knowledge points of instruction system
India plans to ban China Telecom equipment! Can we really do without Huawei and ZTE?
Bitwise and, or, XOR and other operation methods
5、动态规划---斐波那契数列
AP Autosar平台设计 1-2 导言、技术范围与方法
Ueeditor v1.4.3 control file compression
9. Delete nodes in the linked list
2021-10-13arx
9、删除链表中节点
Hurun released the 2020 top 10 Chinese chip design private enterprises: Huawei Hisilicon did not appear on the list!
4. Adjust the array order so that odd numbers precede even numbers
死锁算法:银行家算法和安全性算法
20200229训练赛 L2 - 2 树种统计 (25分)
11. Linked list inversion
Netease written test No. 2 -- typical application of European distance
It is said that the global semiconductor equipment giant may build a joint venture factory in Shanghai!