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; }總結
以上是生活随笔為你收集整理的Codeforces Round #552 (Div. 3) —— A. Restoring Three Numbers的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 蓝桥杯练习系统 —— 题解目录
- 下一篇: 经典数学问题:Nim游戏