Please Fill out the Feedback Form for Code Radius

Blitz : BLICZ | CodeChef Solution

2 min read

Problem

In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b 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. \left\lfloor \frac{N+1}{2} \right\rfloor⌊2N+1​⌋ moves made by white and \left\lfloor \frac{N}{2} \right\rfloor⌊2N​⌋ moves made by black), the game ends and the clocks of the two players stop; they show that the players (white and black) have A and B seconds left respectively. Note that after the N-th turn, b = 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 Format

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains three space-separated integers N, A and B..

Output Format

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

Constraints

Sample

Input
3
10 0 2
11 2 1
12 192 192
Output
378
379
0

Explanation

Example case 1: The total time given to both clocks after 1010 turns is 2 \cdot (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 \cdot (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..

Solution

cpp
#include <iostream> using namespace std; // Solution from : Code Radius [ https://radiuscode.blogspot.com/ ] int main() { int t,x,y; cin>>t; for(int i=0;i<t;i++) { int a,b,c; cin>>a>>b>>c; x=2*(180+a); y=b+c; cout<<(x-y)<<endl; } return 0; }

Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem In mathematics, the degree of polynomials in one variable is the highest power of the variable in the algebraic expression with non-zero coefficient.Chef has a polynomial…
  •  ProblemChefland has 2 different types of coconut, type A and type B. Type A contains only x_a milliliters of coconut water and type B contains only x_b grams of coconut pulp.…
  • ProblemYou and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into h…
  • ProblemIf Give an integer N . Write a program to obtain the sum of the first and last digits of this number. Please Share this article... Input Format The first line contains a…
  •  ProblemChef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play a single song on a loop. Today, …
  • ProblemAlice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice…

Post a Comment