Count Votes Problem Code: ELEC_24 Answer

Count Votes Problem Code: ELEC_24 Answer » Code SMASH! » Count Votes

Count Votes

Problem Code: ELEC_24


Add problem to Todo list
Submit

The yearly elections, for the Class Representative, in which three candidates participated, namely John, Reese and Dwight, have recently ended. John received x votes, Reese received y votes, Dwight received z votes. For each of the candidates, calculate: How many votes should be added to "this" candidate's vote so that he/she wins the CR election, i.e. the number of votes for "this" candidate should be strictly greater than the individual votes of the other two candidates.

Also, note that the added votes for any of the candidates do not affect the vote count when getting the answer for the other two candidates.

Input Format

-> The first line contains one integer T, denoting the number of test cases. Then T test cases follow.

-> Each test case consists of one line containing three integers x, y, and z (0≤x,y,z≤109).

Output Format

For each test case, output in a separate line three integers a1, a2, and a3 (a1,a2,a3 ≥0) separated by spaces— the answer to the problem for the John, Reese, and Dwight, respectively.

Constraints

1≤T≤104
0≤x,y,z≤109

Sample Input 1 

3
0 0 4
10 75 15
13 13 13

Sample Output 1 

5 5 0
66 0 61
1 1 1

Explanation

Test Case #2- John has 10 votes, but to win he needs to have the most votes. In this case, John need 76 votes(max of all three participants) to outperform Reese, who happens to have 75 votes. John already has 10 votes, thus he requires 76−10=66 votes to get a clear majority. Reese is clearly winning with a majority, so she needs no more votes to win. Thus 0 more votes. Similarly, Dwight has 15 votes, but he needs to have minimum of 76 votes to gain absolute majority. So he needs 76−15=61 votes to win the election




             


Post a Comment

0 Comments