zoukankan      html  css  js  c++  java
  • Codeforces Round #552 (Div. 3) —— A. Restoring Three Numbers

    A. Restoring Three Numbers

    A.恢复三个数字

    time limit per test1 second
    每次测试的时间限制1秒
    memory limit per test256 megabytes
    每个测试的内存限制256兆字节
    input standard input
    输入 标准输入
    output standard output
    输出 标准输出
    Polycarp has guessed three positive integers a, b and c.
    Polycarp猜测了三个正整数a、b和c。
    He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number).
    他对这些数字保密,但他把四个数字按任意顺序写在黑板上——它们的对和(三个数字)和所有三个数字的和(一个数字)。
    So, there are four numbers on a board in random order: a+b, a+c, b+c and a+b+c.
    所以,一块电路板上有四个随机排列的数字:A+B,A+C,B+C和A+B+C。

    You have to guess three numbers a, b and c using given numbers.
    你必须用给定的数字猜测三个数字A、B和C。
    Print three guessed integers in any order.
    按任意顺序打印三个猜测的整数。

    Pay attention that some given numbers a, b and c can be equal (it is also possible that a=b=c).
    注意一些给定的数字a、b和c可以相等(也可能是a=b=c)。

    Input

    输入

    The only line of the input contains four positive integers x1,x2,x3,x4 (2≤xi≤109) — numbers written on a board in random order.
    输入的唯一行包含四个正整数x1、x2、x3、x4(2<=xi<=10^ 9 ^)-以随机顺序写入板上的数字。
    It is guaranteed that the answer exists for the given number x1,x2,x3,x4.
    保证给定数字x1、x2、x3、x4的答案存在。

    Output

    输出

    Print such positive integers a, b and c that four numbers written on a board are values a+b, a+c, b+c and a+b+c written in some order.
    打印这样的正整数A、B和C,在一块板上写的四个数字是按某种顺序写的值A+B、A+C、B+C和A+B+C。
    Print a, b and c in any order.
    按任意顺序打印A、B和C。
    If there are several answers, you can print any.
    如果有几个答案,你可以打印任何答案。
    It is guaranteed that the answer exists.
    保证答案存在。

    Examples

    input
    3 6 5 4
    output
    2 1 3
    input
    40 40 40 60
    output
    20 20 20
    input
    201 101 101 200
    output
    1 100 100

    code

    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main()
    {
        int num[4];
        cin>>num[0]>>num[1]>>num[2]>>num[3];
        sort(num,num+4);
        cout<<num[3]-num[0]<<' '<<num[3]-num[1]<<' '<<num[3]-num[2]<<endl;
        return 0;
    }
    
  • 相关阅读:
    概率论
    Python3爬虫爬取淘宝商品数据
    利用Python数据分析基础
    Linux安装MATLAB2016a
    python3爬取高清壁纸(2)
    python3爬取高清壁纸(1)
    Git使用基础
    Python3基础
    正则表达式的使用基础
    Nginx配置多域名代理
  • 原文地址:https://www.cnblogs.com/AlexKing007/p/12338422.html
Copyright © 2011-2022 走看看