Algorithm


A. Elections
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The elections in which three candidates participated have recently ended. The first candidate received a votes, the second one received b votes, the third one received c votes. For each candidate, solve the following problem: how many votes should be added to this candidate so that he wins the election (i.e. the number of votes for this candidate was strictly greater than the number of votes for any other candidate)?

Please note that for each candidate it is necessary to solve this problem independently, i.e. the added votes for any candidate do not affect the calculations when getting the answer for the other two candidates.

Input

The first line contains one integer t (1t1041≤�≤104) — the number of test cases. Then t test cases follow.

Each test case consists of one line containing three integers ab, and c (0a,b,c1090≤�,�,�≤109).

Output

For each test case, output in a separate line three integers AB, and C (A,B,C0�,�,�≥0) separated by spaces — the answers to the problem for the first, second, and third candidate, respectively.

Example
input
Copy
5
0 0 0
10 75 15
13 13 17
1000 0 0
0 1000000000 0
output
Copy
1 1 1
66 0 61
5 5 0
0 1001 1001
1000000001 0 1000000001

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;
  cin>>t;
  int a, b, c;
  while(t--){
    cin>>a>>b>>c;
    if(a > b && a > c){
      cout<<(a - a)<<" "<<( a- b + 1)<<" "<<(a - c + 1)<<endl;
      continue;
    }
    if(b > a && b > c){
      cout<<(b - a + 1)<<" "<<( b- b)<<" "<<(b - c + 1)<<endl;
      continue;
    }
    if(c > a && c > b){
      cout<(c - a + 1)<" "<( c- b + 1)<" "<(c - c)<endl;
      continue;
    }
    if(a == b && a > c){
      cout<(a - a + 1)<" "<( a- b + 1)<" "<(a - c + 1)<endl;
      continue;
    }
    if(b == c && b > a){
      cout<(b - a + 1)<" "<( b- b + 1)<" "<(b - c + 1)<endl;
      continue;
    }
    if(c == a && c > b){
      cout<<(c - a + 1)<<" "<<( c- b + 1)<<" "<<(c - c + 1)<<endl;
      continue;
    }
    if(a == b && b == c){
      cout<<1<<" "<<1<<" "<<1<<endl;
      continue;
    }
  }

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
0 0 0
10 75 15
13 13 17
1000 0 0
0 1000000000 0

Output

x
+
cmd
1 1 1
66 0 61
5 5 0
0 1001 1001
1000000001 0 1000000001
Advertisements

Demonstration


Codeforcess Solution 1593-A A. Elections ,C++, Java, Js and Python ,1593-A,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+