Submit | All submissions | Best solutions | Back to list |
MOHIB - Mohib and series |
Mohib (), as we all known, is very brilliant in mathematics. His friend Bar has given him another problem to solve.
Bar gives him a sequence of distinct positive integers, whose average is (A+1).
If Bar append an integer x to the sequence, then the average of integers in the sequence will be A.
He asked the Mohib to tell him the largest possible integer in the sequence.
Input
First line contains T, the number of testcases (T <= 5000).
Next T lines contain an integer x (1 <= x <= 49999) and A (x+1 <= A <= 50000).
Output
Print the largest possible integer in the sequence.
Example
Input: 1 1 2 Output: 3
Added by: | MoHib85 |
Date: | 2015-05-17 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ADA95 ASM32-GCC ASM32 ASM64 GAWK BASH JS-MONKEY |
hide comments
|
||||||||||
2015-08-07 15:56:19 alok singh
green in one go easy ques..... :p |
||||||||||
2015-08-01 08:52:07 Piyush Nirmal
nice and easy!! |
||||||||||
2015-06-28 19:01:24 AlphaDecay
Number X need not be distinct. ! |
||||||||||
2015-06-27 22:23:12 janina
easy one.....green in one go :) |
||||||||||
2015-06-15 08:35:44 :.Mohib.:
@soma there is some mistakes in your formula...and there is no need to use fast I/O u can use scanf/printf....All the best... :) |
||||||||||
2015-06-12 14:42:14 Soma
@author : for what kind of test data i am getting WA. code id : 14441023 Last edit: 2015-06-13 10:20:35 |