Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】
来源:互联网 发布:古墓丽影8for mac 编辑:程序博客网 时间:2024/06/05 03:32
Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot
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 npieces 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
题解: 等腰三角形的高和底部 缩小是成比例的
那么面积是1/n 比例为x 那么x*1*h*x/2=(1/n) h/2
那么算出这个比例就可以了
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
#define read(); freopen("C:\\Users\\Administrator\\Desktop\\input.txt","r",stdin);
typedef long long ll;
using namespace std;
double h,n;
int main()
{
cin>>n>>h;
double area=h/2;
for(int i=1;i<n;i++){
double k=sqrt(area*(i/n)*2/h);
printf("%0.13lf ",k*h);
}
return 0;
}
- Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A. Carrot Cakes
- (Codeforces Round #413, rated, Div. 1 + Div. 2)(A+B)
- Codeforces Round #413 Div. 1 + Div. 2 A. Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B. T-shirt buying
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B
- Codeforces Round #414 B. Cutting Carrot 几何二分
- Educational Codeforces Round 33 (Rated for Div. 2) B
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)B题B. T-shirt buying
- Codeforces Round #414, rated, Div. 1 + Div. 2 A. Bank Robbery
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) B. Valued Keys
- Educational Codeforces Round 33 (Rated for Div. 2) 893B. Beautiful Divisors
- Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) B HIGH ROAD
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains(树状数组)
- AndroidFlux项目一览-Flux架构的Android移植
- 《数据库原理(第5版)》(样章).pdf
- 15 个 Android 通用流行框架大全
- Oracle RAC 中 crsctl start/stop crs 和 crsctl start/stop cluster 区别
- 文章标题
- Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】
- 深度卷积对抗生成网络(DCGAN)
- Windows 7各版本比较
- Qt入门(3)——信号槽
- 2017.5.13--第一天
- 安卓消息处理机制 【安卓似懂非懂的小知识点】首篇
- 《深入理解Java虚拟机——JVM高级特性与最佳实践(第2版)》pdf
- 软件工程-1.概述
- 使用递归求全排列