codeforce B. Cutting Carrot

来源:互联网 发布:西安交通网络教育学院 编辑:程序博客网 时间:2024/06/08 05:54

题目链接:点击打开链接

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 - 1cuts 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.
Input

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

Output

The output should contain n - 1 real numbers x1, x2, ..., xn - 1. The number xi denotes that the i-th cut must be made xi units away from the apex of the carrot. In addition, 0 < x1 < x2 < ... < xn - 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 .

Examples
input
3 2
output
1.154700538379 1.632993161855
input
2 100000
output
70710.678118654752
Note

Definition of isosceles triangle: https://en.wikipedia.org/wiki/Isosceles_triangle.


数学知识,还好我还记得。就是相似三角形,知道面积比,求高。因为大三角形的高已知,所以小三角形的高很容易算出,i从1到n-1,高正好完成排序。


代码实现:

#include<iostream>#include<cmath>#include<algorithm>#include<cstdio>using namespace std;int main(){long long n,h,i;double a[1005];while(scanf("%d%d",&n,&h)!=EOF){for(i=1;i<n;i++){a[i]=sqrt(i/(n*1.0))*h;}printf("%.12llf",a[1]);for(i=2;i<n;i++){printf(" %.12llf",a[i]);}printf("\n");}return 0;}


0 0