博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces 158B (数学)
阅读量:4608 次
发布时间:2019-06-09

本文共 2290 字,大约阅读时间需要 7 分钟。

B. Mushroom Scientists
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

As you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (x, y, z). In this coordinate system, the distance between the center of the Universe and the point is calculated by the following formula: . Mushroom scientists that work for the Great Mushroom King think that the Universe isn't exactly right and the distance from the center of the Universe to a point equals xa·yb·zc.

To test the metric of mushroom scientists, the usual scientists offered them a task: find such x, y, z (0 ≤ x, y, zx + y + z ≤ S), that the distance between the center of the Universe and the point (x, y, z) is maximum possible in the metric of mushroom scientists. The mushroom scientists aren't good at maths, so they commissioned you to do the task.

Note that in this problem, it is considered that 00 = 1.

Input

The first line contains a single integer S (1 ≤ S ≤ 103) — the maximum sum of coordinates of the sought point.

The second line contains three space-separated integers abc (0 ≤ a, b, c ≤ 103) — the numbers that describe the metric of mushroom scientists.

Output

Print three real numbers — the coordinates of the point that reaches maximum value in the metrics of mushroom scientists. If there are multiple answers, print any of them that meets the limitations.

A natural logarithm of distance from the center of the Universe to the given point in the metric of mushroom scientists shouldn't differ from the natural logarithm of the maximum distance by more than 10 - 6. We think that ln(0) =  - ∞.

Sample test(s)
input
3 1 1 1
output
1.0 1.0 1.0
input
3 2 0 0
output
3.0 0.0 0.0

 SL: 

  1 // by caonima

 2 
//
 hehe
 3 
#include <bits/stdc++.h>
 4 
using 
namespace std;
 5 
const 
int MAX= 1e5+
10;
 6 
int main() {
 7     
double S,a,b,c;
 8     
double x,y,z;
 9     
while(scanf(
"
%lf
",&S)==
1) {
10         scanf(
"
%lf %lf %lf
",&a,&b,&c);
11         
if(a==
0&&b==
0&&c==
0) printf(
"
0.0 0.0 0.0\n
");
12         
else {
13             x=a*S/(a+b+c); y=b*S/(a+b+c); z=c*S/(a+b+c);
14             printf(
"
%.15lf %.15lf %.15lf\n
",x,y,z);
15         }
16     }
17     
return 
0;
18 }

 

转载于:https://www.cnblogs.com/acvc/p/3899420.html

你可能感兴趣的文章
【Vjudge】P1989Subpalindromes(线段树)
查看>>
ExtJs之Ext.util.TaskRunner
查看>>
Solved problems updating perl-XML-SAX-0.96-7.el6.noarch on CentOS 6
查看>>
redis为什么快
查看>>
【树状数组(二叉索引树)】轻院热身—candy、NYOJ-116士兵杀敌(二)
查看>>
116830
查看>>
c#,将pdf文件转换成图片文件。
查看>>
美国 100 名以后的大学还有去读研究生的必要吗?[无聊的时候看看]
查看>>
吴昊品游戏核心算法 Round 12(特别篇) —— 吴昊教你玩筷子游戏(计算几何)
查看>>
nginx的域名解析
查看>>
thymeleaf 拼接 超链接
查看>>
Linux基础命令---swapon
查看>>
memset() - 按字节赋值
查看>>
在MAC端查看win7
查看>>
将asi-http-request引入到ARC工程需要做的
查看>>
Asp.Net MVC 5使用Identity之简单的注册和登陆
查看>>
client、page、screen、scroll
查看>>
回调函数
查看>>
周鸿祎:从用户骂声中发现用户需求
查看>>
【转载】softmax的log似然代价函数(求导过程)
查看>>