寒假比赛第二场平分胡萝卜

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

The first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ 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 .

Example
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
题目的意思是,要把h高的胡萝卜分为面积相等的n段
运用三角形相似和三角形面积公式

设三角形底边为d
例如
3 2

d2/d3=h2/h3;

d2*h2=2/3*h3*d3;
h2*h2/h3*h3=2/3;

h1*h1/h3*h3=1/3;
hi*hi/hn*hn=i/n;

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
    int h,i,j,p,k,l,d;double a[10001],f;
    scanf("%d %d",&d,&h);
for(i=1;i<d;i++)
    {f=(1.0*i/d)*h*h;
a[i]=sqrt(f);}
for(i=1;i<d-1;i++)
    printf("%.12lf ",a[i]);
    printf("%.12lf\n",a[d-1]);

    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值