Problem
In a Chess match "a + b", each player has a clock which shows minutes at the start and whenever a player makes a move, seconds are added to this player's clock. Time on a player's clock decreases during that player's turns and remains unchanged during the other player's turns. If the time on some player's clock hits zero (but not only in this case), this player loses the game.
There's a 3 + 2 blitz chess match. After turns (i.e. moves made by white and moves made by black), the game ends and the clocks of the two players stop; they show that the players (white and black) have and seconds left respectively. Note that after the -th turn, seconds are still added to the clock of the player that made the last move and then the game ends.
Find the total duration of the game.
Input
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains three space-separated integers , and .
Output
For each test case, print a single line containing one integer — the duration of the game.
Constraints
- for odd,
- for even,
- there is at least one valid game consistent with the input
Example Input
3
10 0 2
11 2 1
12 192 192
Example Output
378
379
0
Explanation
Example case 1: The total time given to both clocks after turns is seconds. The total time left at the end is seconds. The duration of the game is seconds.
Example case 3: The total time given to both clocks after turns is seconds. The total time left at the end is seconds. The duration of the game is seconds.
Program :
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
while((test--)>0){
int n = Integer.parseInt(sc.next());
int sum = 2*(180+n);
sum = sum - (Integer.parseInt(sc.next())+Integer.parseInt(sc.next()));
System.out.println(""+sum);
}
}
}
0 Comments