# Blitz Problem: BLICZ

### Blitz Problem Codechef solution

In a Chess match “a + b”, each player has a clock which shows aa minutes at the start and whenever a player makes a move, bb 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 NN turns (i.e. ⌊N+12⌋⌊N+12⌋ moves made by white and ⌊N2⌋⌊N2⌋ moves made by black), the game ends and the clocks of the two players stop; they show that the players (white and black) have AA and BB seconds left respectively. Note that after the NN-th turn, b=2b=2 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 TT denoting the number of test cases. The description of TT test cases follows.
• The first and only line of each test case contains three space-separated integers NN, AA and BB.

### Output

For each test case, print a single line containing one integer — the duration of the game.

### Constraints

• 1≤T≤1051≤T≤105
• 10≤N≤10010≤N≤100
• 0≤A≤180+2⋅⌊N+12⌋0≤A≤180+2⋅⌊N+12⌋
• 0≤B≤180+2⋅⌊N2⌋0≤B≤180+2⋅⌊N2⌋
• for NN odd, A≥2A≥2
• for NN even, B≥2B≥2
• 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 1010 turns is 2⋅(180+10)=3802⋅(180+10)=380 seconds. The total time left at the end is 0+2=20+2=2 seconds. The duration of the game is 380−2=378380−2=378 seconds.

Example case 3: The total time given to both clocks after 1212 turns is 2⋅(180+12)=3842⋅(180+12)=384 seconds. The total time left at the end is 192+192=384192+192=384 seconds. The duration of the game is 384−384=0384−384=0 seconds.

## Blitz Problem Codechef solution in C++ 14

``````
int main()
{
int t;
cin>>t;
while(t--)
{
int n,a,b;
cin>>n>>a>>b;
cout << 360+2*n-(a+b) << "\n";

}
return 0;
}``````

## Blitz Problem Codechef solution in Python 3

``````T = int(input(""))
for i in range (0,T):
n,a,b = map(int,input().split())
t = 2*(180+n)
tl = a+b
d = t-tl
print(d)
``````

## Blitz Problem Codechef solution in Java

``````/* 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
{
Scanner sc=new Scanner(System.in);
int tests = sc.nextInt();
for(int i=0;i < tests;i++){
int a =sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d =180;
int m=d+a;
int e= 2*m;
int f=b+c;
int h=e-f;
System.out.println(h);
}
}
}``````