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-05-20 10:32:54 __hk__
AC in 1st go!!! |
|||||||||
2015-05-19 07:00:38 Shubham Sinha
Pay attention to the word "distinct" costed me 2 wa's. |
|||||||||
2015-05-19 04:12:38 :.Mohib.:
@Tony there is a unique sequence.... in sample testcase the sequence would be 1, 3 Which avg.=2....but after removing x which is 1,avg would be 3.... |
|||||||||
2015-05-19 01:20:17 Vaporeon
Got AC in first attempt! :D .. Problem statement could have been clearer... :) |
|||||||||
2015-05-19 00:53:33 Tony Stark
Does sequence here refer to any special sequence or just a set of positive numbers? |
|||||||||
2015-05-18 12:20:10 mehmetin
Something must be wrong with the system. I sent my cpp file 15 times, but the judge took it for empty code and gave WA. I sent the same code with online editor and got accepted. Edit: It works fine now. Last edit: 2015-05-18 17:49:24 |