QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11837. Sheets [A]

統計

Little John has just started to learn about the addition operation at school. His mother came up with a new game which can help John with learning. At the beginning of the game, John's mother writes all integer numbers in the range from 1 to $ n $ on separate sheets of paper. She then forms a row of sheets, keeping the order of numbers on sheets unchanged (from 1 to $ n $). John's task is to perform a given action a number of times. The action consists of: picking up $ k $ first sheets from the row, summing up the numbers written on these sheets, tearing and throwing away those sheets and writing the obtained sum on a new sheet and locating it at the end of the row. If at some point of the game there are less than $ k $ sheets in the row, John doesn't worry about it and he adds the values of all the remaining sheets.

John really enjoys the new game. He keeps asking his mother to check whether he has made any mistake while calculating the consecutive sums. What is more, John plays this game really well so he tries his chances for bigger and bigger values of $ n $ and $ k $. John's mother can't keep up with checking the results obtained by John, so she asked you to write a program that will validate the results for her.

Write a program which:

  • reads numbers n, $ k $ and $ r $ from the standard input,
  • calculates what the sum should be written by John in the $ r $-th move,
  • writes the result to the standard output.

Input Format

In the first line of the standard input there is one integer $ t $ ($1 ≤ t ≤ 100$) which denotes the number of queries to proceed. Each query is located in a separate line and is represented by three integers $ n $, $ k $ and $ r $ ($1 ≤ n, k, r ≤ 10^{9}$), separated by single spaces. Such a query asks for a number which John should write on the sheet in the $ r $-th move in the game represented by parameters $ n $ and $ k $.

Output Format

Output should consist of $ i $ lines. $ i $-th line should contain one integer - the answer to the $ i $-th query.

Example

Input

6
6 2 1
6 2 2
6 2 3
6 2 4
6 2 5
6 2 6

Output

3
7
11
10
21
21
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.