A Valentine Gift
All submissions for this problem are available.
Anand buys N gifts for his girlfriend Riyasa on Valentine's Day. Each gift has a unique number on it with the numbers ranging from 1 to N. When Anand reaches
Riyasa's home, he finds that he has lost 2 gifts. But Anand knows the sum of the numbers on the remaining gifts which is equal to K. Riyasa loves puzzles and seeing
the situation asks Anand to find the minimum product of the numbers on the two lost gifts. Anand is a little weak in Maths, so you have to help him in solving the
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains two integers N and K as described above.
- For each test case, output a single line containing the minimum product as described above. If no solution is possible, print -1
- 1 ≤ T ≤ 1000
- 2 ≤ N ≤ 10000
- 0 ≤ K ≤ 10000
Input: 2 2 0 3 3 Output: 2 2 Explanation Case 1 : The 2 lost numbers are 1 and 2.Their product comes out to be 2.This is the only way possible
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2|
Fetching successful submissions