Codeforces Round #552 (Div. 3) A.Restoring Three Numbers

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yuewenyao/article/details/89398887

传送门

Polycarp has guessed three positive integers aa , bb and cc . 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 .

You have to guess three numbers a , b and c using given numbers. 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 ).

Input

The only line of the input contains four positive integers x1,x2,x3,x4 (2≤xi≤1092≤xi≤109 ) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number x1,x2,x3,x4x1,x2,x3,x4 .

Output

Print such positive integers aa , bb and cc that four numbers written on a board are values a+ba+b , a+ca+c , b+cb+c and a+b+ca+b+c written in some order. Print aa , bb and cc in any order. 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

题意:给你四个数字让你猜他自己想要的三个数字,第一个数字代表a+b,第二个数字代表a+c,第三个数字代表b+c,第四个数字代表a+b+c,我们可以想,首先对这四个数字进行一个排序,然后找到最大的那个通过for循环依次减去前边的数字就是答案,可以想一下。

#include<bits/stdc++.h>
using namespace std;
int main(){
  int s[5];
  for(int i = 0 ; i < 4 ; i ++){
    cin >> s[i];
  }
  sort(s,s+4);
  for(int i = 0 ; i < 3 ; i ++){
    printf("%d ",s[3] - s[i]);
  }
  printf("\n");
}

猜你喜欢

转载自blog.csdn.net/yuewenyao/article/details/89398887