1.题目描述:
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?

The first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ h ≤ 105).
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 .
3 2
1.154700538379 1.632993161855
2 100000
70710.678118654752
Definition of isosceles triangle: https://en.wikipedia.org/wiki/Isosceles_triangle.
2.题意概述:
给你一个等腰三角形,要你用n-1条垂直于高的直线将它们分成n等份,问这些直线的坐标。
3.解题思路:
既然是n等份,即每份的面积为总面积的1/n,因为三角形更好算,考虑从上往下分,前i份组成的三角形所占面积为i/n,即Si/Sn=i/n。
而由相似三角形容易得Si/Sn=Xi^2/n^2,那么再利用三角形面积公式就出来了。
PS:开始没想到那个相似三角形公式,而是推了一遍带tan的数,可能是爆精度了,样例都没过QAQ
4.AC代码:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 100100
#define lson root << 1
#define rson root << 1 | 1
#define lent (t[root].r - t[root].l + 1)
#define lenl (t[lson].r - t[lson].l + 1)
#define lenr (t[rson].r - t[rson].l + 1)
#define N 1111
#define eps 1e-6
#define pi acos(-1.0)
#define e exp(1.0)
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
double n, h;
double ans[1001];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
long _begin_time = clock();
#endif
int a,b;
while (~scanf("%d%d", &a, &b))
{
for (int i = 1; i < a; i++)
{
double temp = i;
if (i == 1)
printf("%.10f", b*sqrt(temp / a));
else
printf(" %.10f", b*sqrt(temp / a));
}
puts("");
}
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %ld ms.", _end_time - _begin_time);
#endif
return 0;
}