Leaderboard
Showing:
Ishaan's Weight
Basic Accuracy: 19.87% Submissions: 3367 Points: 1

Ishaan is getting really fat. He wants to lose his weight but can't get the motivation to workout. Seeing this, his friend Charul offers him a deal.
For every K pushups Ishaan does, Charul will give him money equal to the number of pushups Ishaan has done till then (Refer Example for Explanation).
Find out the amount of money he made if he does N pushups.

Input : 
The first line of input contains a single integer T denoting the number of test cases.
The only line of each test case contains 2 space-separated integers N and K.

Output : 
For each test case, print the required answer in a new line.

Constraints : 
1 <= T <= 200
1 <= N <= 10^9
1 <= K <= 10^5

Example : 
Input : 

3
5 2
5 3
5 6
Output : 
6
3
0

Explanation : 
Case 1 : 
Pushup 1: No Money
Pushup 2: +2
Pushup 3: No Money
Pushup 4: +4
Pushup 5: No Money

Case 2 : 
Pushup 1: No Money
Pushup 2: No Money
Pushup 3: +3
Pushup 4: No Money
Pushup 5: No Money

Case 3 : 
Pushup 1: No Money
Pushup 2: No Money
Pushup 3: No Money
Pushup 4: No Money
Pushup 5: No Money

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Ishaan's Weight

Output Window