Equipment Loan Calculator
Preview mode. Log in to edit, run, submit, and save progress.
Equipment Loan Calculator
A trainee buys equipment over w days. On day i, counted from 1, the equipment costs k*i credits. The trainee already has n credits. For each purchase plan, compute how many extra credits must be borrowed so every day can be paid for. If the trainee already has enough credits, the borrowed amount is 0. Input Format: The first line contains t, the number of test cases. Each test case contains k, n, and w. Output Format: For each test case, print the number of extra credits required.
Examples
1 3 17 4
13
Explanation: The four daily costs are 3, 6, 9, and 12, for a total of 30. With 17 credits available, 13 more are needed.
Approach hint
Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.