A10927 | Cutting Carrot
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Igor the analyst has adopted $n$ little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into $n$ pieces of equal area.
Formally, the carrot can be viewed as an isosceles triangle with base length equal to $1$ and height equal to $h$ . Igor wants to make $n-1$ cuts parallel to the base to cut the carrot into $n$ pieces. He wants to make sure that all $n$ pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?
Illustration to the first example.
Formally, the carrot can be viewed as an isosceles triangle with base length equal to $1$ and height equal to $h$ . Igor wants to make $n-1$ cuts parallel to the base to cut the carrot into $n$ pieces. He wants to make sure that all $n$ pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?
Illustration to the first example.
输入格式
The first and only line of input contains two space-separated integers, $n$ and $h$ ( $2<=n<=1000$ , $1<=h<=10^{5}$ ).
输出格式
The output should contain $n-1$ real numbers $x_{1},x_{2},...,x_{n-1}$ . The number $x_{i}$ denotes that the $i$ -th cut must be made $x_{i}$ units away from the apex of the carrot. In addition, $0<x_{1}<x_{2}<...<x_{n-1}<h$ must hold.
Your output will be considered correct if absolute or relative error of every number in your output doesn't exceed $10^{-6}$ .
Formally, let your answer be $a$ , and the jury's answer be $b$ . Your answer is considered correct if .
Your output will be considered correct if absolute or relative error of every number in your output doesn't exceed $10^{-6}$ .
Formally, let your answer be $a$ , and the jury's answer be $b$ . Your answer is considered correct if .
输入输出样例
输入 #1
3 2
输出 #1
1.154700538379 1.632993161855
输入 #2
2 100000
输出 #2
70710.678118654752
Definition of isosceles triangle: [https://en.wikipedia.org/wiki/Isosceles\_triangle](https://en.wikipedia.org/wiki/Isosceles_triangle).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted