Codeforces 158B (数学)
2 seconds
256 megabytes
standard input
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, z; x + 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.
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 a, b, c (0 ≤ a, b, c ≤ 103) — the numbers that describe the metric of mushroom scientists.
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) = - ∞.
3
1 1 1
1.0 1.0 1.0
3
2 0 0
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+;
6 int main() {
7 double S,a,b,c;
8 double x,y,z;
9 while(scanf("%lf",&S)==) {
scanf("%lf %lf %lf",&a,&b,&c);
if(a==&&b==&&c==) printf("0.0 0.0 0.0\n");
else {
x=a*S/(a+b+c); y=b*S/(a+b+c); z=c*S/(a+b+c);
printf("%.15lf %.15lf %.15lf\n",x,y,z);
}
}
return ;
}
Codeforces 158B (数学)的更多相关文章
- CodeForces - 158B.Taxi (贪心)
CodeForces - 158B.Taxi (贪心) 题意分析 首先对1234的个数分别统计,4人组的直接加上即可.然后让1和3成对处理,只有2种情况,第一种是1多,就让剩下的1和2组队处理,另外一 ...
- Sonya and Matrix CodeForces - 1004D (数学,构造)
http://codeforces.com/contest/1004/problem/D 题意:网格图给定到中心点的曼哈顿距离数组, 求该图n,m及中心点位置 首先可以观察到距离最大值mx一定在某个角 ...
- CodeForces 621C 数学概率期望计算
昨天训练赛的题..比划了好久才想出来什么意思 之前想的是暴力for循环求出来然后储存数组 后来又想了想 自己萌的可以.. 思路就是求出来每个人与他的右边的人在一起能拿钱的概率(V(或)的关系)然后*2 ...
- CodeForces 158B Taxi(贪心)
贪心,注意优先级,4单独,3与1先匹配,2与2匹配(注意判断2有没有剩下),然后2与两个1匹配,最后4个1匹配就可以了. #include<iostream> #include<cs ...
- Sasha and a Very Easy Test CodeForces - 1109E (数学,线段树)
大意: 给定n元素序列, q个操作: (1)区间乘 (2)单点除(保证整除) (3)区间求和对m取模 要求回答所有操作(3)的结果 主要是除法难办, 假设单点除$x$, $x$中与$m$互素的素因子可 ...
- Codeforces 158B:Taxi
B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input outpu ...
- CodeForces 484B 数学 Maximum Value
很有趣的一道题,题解戳这. #include <iostream> #include <cstdio> #include <cstring> #include &l ...
- Codeforces 300E(数学)
题意:给定k个数字,求最小的正整数n,使得“n的阶乘”是“这k个数字的阶乘的积”的倍数.1<=k<=1e6,数字ai满足1<=ai<=1e7 分析:如果我们能对着k个数字的阶乘 ...
- 【Codeforces 158B】Taxi
[链接] 我是链接,点我呀:) [题意] 每辆车可以载重4个人. 一共有n个组,每个组分别有s[i]个人. 要求每个组的人都在同一辆车里面. 问最少需要多少辆车 [题解] 将每个组的人数从小到大排序. ...
随机推荐
- bzoj 1725: [Usaco2006 Nov]Corn Fields牧场的安排【状压dp】
压一维状态,转移时把符合条件的上一行加上 #include<iostream> #include<cstdio> using namespace std; const int ...
- Storm编程入门API系列之Storm的定时任务实现
概念,见博客 Storm概念学习系列之storm的定时任务 Storm的定时任务,分为两种实现方式,都是可以达到目的的. 我这里,分为StormTopologyTimer1.java 和 Sto ...
- [转]MVC之 自定义过滤器(Filter)
本文转自:http://www.cnblogs.com/kissdodog/archive/2013/01/21/2869298.html 一.自定义Filter 自定义Filter需要继承Actio ...
- Elasticsearch--预匹配器
当你对一个无限输入数据流进行操作并搜索特定事件的出现时,可以使用此模型.可以用于检测监控系统中的故障. 在新版本中的知识点位置https://www.elastic.co/guide/en/elast ...
- ES6十大常用特性
. Default Parameters(默认参数) in ES6 2. Arrow Functions (箭头函数)in ES6 3. Block-Scoped Constructs ...
- Apache JServ protocol服务 怎么关闭?
Apache JServ protocol = AJP 解决方案:修改tomcat 的service.xml配置文件 将 <Connector port="8009" ...
- navicat创建存储过程报错
搞了半天这个恶心的报错,最后发现竟然是存储过程的一个varchar类型的参数没给长度,如varchar(64)长度必须指定不然就会报错: mark一记
- 史上最大型广告欺诈活动Methbot:黑客是如何每天赚到500万美元的
根据国外安全专家的最新报告,有一群黑客正在对美国的知名企业和媒体机构进行广告欺诈活动,而这群黑客每天都可以从中赚取三百万到五百万美金. 是的,你没看错,这绝对是人类历史上最牛X的恶意广告欺诈活动!不过 ...
- Exception Information
https://developer.apple.com/library/content/technotes/tn2004/tn2123.html Exception Information The t ...
- 安卓app测试之cpu监控
安卓app测试之cpu监控,如何获取监控的cpu数据呢? 一.通过Dumpsys 来取值 1.adb shell dumpsys cpuinfo 二.top 1.top -d 1|grep packa ...