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
hide comments
Arnabjyoti Kalita:
2016-02-28 10:21:08
Pretty easy--focus on the fact that the initial sequence has distinct numbers... |
|
Jacob Plachta:
2015-12-06 23:48:59
In some cases, x=avg... The expected output in this case is "0". |
|
hmp:
2015-12-06 18:18:27
can any body tell what is runtime error (SIGABRT) in c++
|
|
Arjav Patel:
2015-10-21 19:13:55
Instead of Positive number, it should be positive integer! |
|
xpshekhar:
2015-08-20 21:31:15
@author
|
|
poojan :
2015-08-19 19:27:25
10 minit of paperwork needed !AC in first go! btw good que!
|
|
ranjeetkumar:
2015-08-09 18:20:26
easy one..accepted in one go........ |
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 |