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
scyth3r:
2015-05-22 18:44:44
initial list --> {set of random distinct integers} U {x}
|
|
shan_:
2015-05-22 16:47:28
Is the sequence something special? like consecutive members of an AP?
|
|
tjphoenixrg1:
2015-05-22 10:11:41
I have tried to solve the problem and i can successfully extract the largest possible number from the sequence when the sequence satisfies the condition given. Still, i got the wrong answer. Could someone look at my program and help. I am a beginner at programming. Thank You!
|
|
xMAn:
2015-05-22 06:27:41
are the numbers only integer.. or can be fractional too? |
|
sam:
2015-05-21 20:38:39
plz...check my submision
|
|
__hk__:
2015-05-20 10:32:54
AC in 1st go!!! |
|
Shubham Sinha:
2015-05-19 07:00:38
Pay attention to the word "distinct" costed me 2 wa's. |
|
:.Mohib.::
2015-05-19 04:12:38
@Tony there is a unique sequence.... in sample testcase the sequence would be 1, 3
|
|
Vaporeon:
2015-05-19 01:20:17
Got AC in first attempt! :D .. Problem statement could have been clearer... :) |
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 |