CF794B.Cutting Carrot

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

分析员伊戈尔收养了 nn 只小兔子。众所周知,兔子喜欢吃胡萝卜。因此,伊戈尔买了一根胡萝卜,准备分给他的兔子们。伊戈尔希望公平地对待所有兔子,于是他打算将这根胡萝卜切成 nn 块面积相等的部分。

形式化地说,这根胡萝卜可视为一个底边长度为 11、高为 hh 的等腰三角形。伊戈尔计划作 n−1n-1 次平行于底边的切割,将胡萝卜分成 nn 块,并确保每一块的面积都相等。你能帮伊戈尔确定切割位置,使得每一块面积都相等吗?

第一个样例的示意图。

输入格式

The first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ h ≤ 105).

输入仅有一行,包含两个以空格分隔的整数 nn 和 hh(2 ≤ n ≤ 10002 \le n \le 1000,1 ≤ h ≤ 1051 \le h \le 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 .

输出应包含 n−1n-1 个实数 x1, x2, …, xn−1x_1,\,x_2,\,\dots,\,x_{n-1}。其中,数 xix_i 表示第 ii 次切割必须在距胡萝卜顶点 xix_i 个单位处进行。此外,还需满足 0<x1<x2<⋯<xn−1<h0 < x_1 < x_2 < \dots < x_{n-1} < h。

若输出中每个数的绝对误差或相对误差均不超过 10−610^{-6},则你的输出将被视为正确。

形式化地,设你的答案为 aa,评测机的答案为 bb。当满足 时,你的答案即被视为正确。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页