Array got some moves

All submissions for this problem are available.
An array $[A_1, A_2, ... A_N]$ is said to be a $KMoving$ array if :  Initially all its elements are **positive integers**.  After performing **exactly** $K$ moves on the array, its length becomes $0$. A move is performed in the following way :  Let $X$ be the smallest element in the array. Subtract $X$ from all $A_i$ $(1 \leq i \leq length(A)).$  Remove all the elements from the array which are reduced to $0$ after performing the above move. Let $S$ denote the sum of all elements of the initial array. Given $N$ and $K$, consider all $KMoving$ arrays of length $N$. Your need to find the minimum value of $S$ over all such arrays. ###Input:  First line will contain $T$, number of testcases. Then the testcases follow.  Each testcase consists of a single line of input, two space separated integers $N$ and $K$. ###Output: For each testcase, output in a single line an integer  the minimum value of $S$. ###Constraints  $1 \leq T \leq 10^4$  $1 \leq K \leq N \leq 10^9$ ###Sample Input: 1 3 2 ###Sample Output: 4 ###EXPLANATION: One possible $2Moving$ array of length $3$ with minimum $S$ is $[1,2,1].$ After Move $1$ : The array becomes $[0,1,0]$. After removing zeros, it becomes $[1]$ After Move $2$ : The array becomes $[0]$. After removing zeros, it becomes $[ ]$ Hence the answer is $1+2+1=4.$Author:  enigma27 
Tags  enigma27 
Date Added:  4032019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions