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+;
 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 (数学)的更多相关文章

  1. CodeForces - 158B.Taxi (贪心)

    CodeForces - 158B.Taxi (贪心) 题意分析 首先对1234的个数分别统计,4人组的直接加上即可.然后让1和3成对处理,只有2种情况,第一种是1多,就让剩下的1和2组队处理,另外一 ...

  2. Sonya and Matrix CodeForces - 1004D (数学,构造)

    http://codeforces.com/contest/1004/problem/D 题意:网格图给定到中心点的曼哈顿距离数组, 求该图n,m及中心点位置 首先可以观察到距离最大值mx一定在某个角 ...

  3. CodeForces 621C 数学概率期望计算

    昨天训练赛的题..比划了好久才想出来什么意思 之前想的是暴力for循环求出来然后储存数组 后来又想了想 自己萌的可以.. 思路就是求出来每个人与他的右边的人在一起能拿钱的概率(V(或)的关系)然后*2 ...

  4. CodeForces 158B Taxi(贪心)

    贪心,注意优先级,4单独,3与1先匹配,2与2匹配(注意判断2有没有剩下),然后2与两个1匹配,最后4个1匹配就可以了. #include<iostream> #include<cs ...

  5. Sasha and a Very Easy Test CodeForces - 1109E (数学,线段树)

    大意: 给定n元素序列, q个操作: (1)区间乘 (2)单点除(保证整除) (3)区间求和对m取模 要求回答所有操作(3)的结果 主要是除法难办, 假设单点除$x$, $x$中与$m$互素的素因子可 ...

  6. Codeforces 158B:Taxi

    B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input outpu ...

  7. CodeForces 484B 数学 Maximum Value

    很有趣的一道题,题解戳这. #include <iostream> #include <cstdio> #include <cstring> #include &l ...

  8. Codeforces 300E(数学)

    题意:给定k个数字,求最小的正整数n,使得“n的阶乘”是“这k个数字的阶乘的积”的倍数.1<=k<=1e6,数字ai满足1<=ai<=1e7 分析:如果我们能对着k个数字的阶乘 ...

  9. 【Codeforces 158B】Taxi

    [链接] 我是链接,点我呀:) [题意] 每辆车可以载重4个人. 一共有n个组,每个组分别有s[i]个人. 要求每个组的人都在同一辆车里面. 问最少需要多少辆车 [题解] 将每个组的人数从小到大排序. ...

随机推荐

  1. [App Store Connect帮助]五、管理构建版本(3)在您提交以供审核前选择构建版本

    在提交 App 至“App 审核”前,请(从您为该版本上传的所有构建版本中)选择您想要提交的版本.一个 App Store 版本仅可关联一个构建版本.但是,在提交该版本至“App 审核”之前,您可以任 ...

  2. 【React Native】React Native项目设计与知识点分享

    闲暇之余,写了一个React Native的demo,可以作为大家的入门学习参考. GitHub:https://github.com/xujianfu/ElmApp.git GitHub:https ...

  3. vue.js学习文档

    1.实例化vue对象 new Vue(){ } 2.对象属性 el: 控制的属性 data: 数据存储位置 methods: 方法存储位置 template: 模板样式 computed: 计算属性 ...

  4. 【js】JavaScript parser实现浅析

    最近笔者的团队迁移了webpack2,在迁移过程中,笔者发现webpack2中有相当多的兼容代码,虽然外界有很多声音一直在质疑作者为什么要破坏性更新,其实大家也都知道webpack1那种过于“灵活”的 ...

  5. 解决:org.springframework.tuple.spel.TuplePropertyAccessor

    原来运行调试正常的项目,今天启动时报“java.lang.IllegalStateException: ApplicationEventMulticaster not initialized”错误.从 ...

  6. android序列化(1)Parcelable与Serializable

    1.Android中实现序列化有两个选择 一是实现Serializable接口(是JavaSE本身就支持的),实现Serializable接口非常简单. 一是实现Parcelable接口(是Andro ...

  7. Spring-security自定义配置器

    定义配置器 public final class MyFilterConfigurer<H extends HttpSecurityBuilder<H>> extends Se ...

  8. LN : leetcode 191 Number of 1 Bits

    lc 191 Number of 1 Bits 191 Number of 1 Bits Write a function that takes an unsigned integer and ret ...

  9. Android中出现Error:In (declare-styleable) FontFamilyFont, unable to find attribute android:font

    Android中出现Error:In (declare-styleable) FontFamilyFont, unable to find attribute android:font 解决办法,今天 ...

  10. python实现qq机器人qqbot

    title: python实现qq机器人qqbot tags: python date: 2018-6-1 10:19:00 --- 以下内容为转载 一.介绍 qqbot 是一个用 python 实现 ...