Forgot Password ?
New password will be sent to following email id
Chotu and Chocolate Day
Problem Code : CHOCOLATE
1 4 1
Time Limit :
C , C++ , Java , Python 2
Login to submit your response.
On Chocolate day, Chotu wants to give his girlfriend a box of chocolate. Chotu has a <b>N X N</b> square box and <b>N<sup>2</sup></b> chocolates each having a <b>distinct</b> sweetness value between <b>1</b> and <b>N<sup>2</sup></b>. <br><br> To make the box look attractive Chotu must fill each row with chocolates arranged in increasing value of sweetness. Chotu also knows that his girlfriend loves the number <b>K</b> so he wants to maximize the total sweetness of the </b>K<sup>th</sup></b> column. Help Chotu arrange the chocolate in the box in a way that each row has chocolates with increasing value of sweetness and the total sweetness of <b>K<sup>th</sup></b> column is maximized. <br><br> As there are multiple ways to arrange chocolates, your task is to tell Chotu the maximum possible sweetness he can have for the <b>K<sup>th</sup> </b>column.
First line contains integer <b>T</b> denoting number of testcases. Each testcase has two integers <b>N</b> and <b>K</b>.
For each test case print answer in single line the maximum possible sweetness Chotu can have for the <b>K<sup>th</b></b> column.
1 <= <b>T</b> <= 20 <br> 1 <= <b>N</b> <= 10<sup>3</sup><br> 1 <= <b>K</b> <= N <br>
For the given sample case one possible arrangement of chocolates is <br> 1 2 3 4<br> 5 6 7 8<br> 9 10 11 12<br> 13 14 15 16<br> The total sweetness of first column is 28.