zoukankan      html  css  js  c++  java
  • Codeforces 158B (数学)

    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 ");
    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 ",x,y,z);
    15         }
    16     }
    17     return 0;
    18 }
  • 相关阅读:
    ios启动画面
    不让精灵移除屏幕外 重写setPosition方法
    post和get请求方式的区别
    IOS开发之手势——UIGestureRecognizer 共存
    Xcode 中的GDB的命令
    [UIView beginAnimations:context:]与[UIView animateWithDuration:animations:]值得注意的一个区别
    应用图标 ICON
    cocos2d 1.01不能运行以前版本工程的问题
    SQL 中数据类型的转换 转
    SQL Server中sql语句执行时间
  • 原文地址:https://www.cnblogs.com/acvc/p/3899420.html
Copyright © 2011-2022 走看看