Interview Questions/Coding/Cashback Fuel Ledger

Cashback Fuel Ledger

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Cashback Fuel Ledger

A procurement ledger starts with n fuel credits. Each purchase spends one credit and creates one receipt. Whenever the buyer has at least ten receipts, ten receipts can be exchanged for one additional credit, and a purchase made with that extra credit also creates a new receipt. For each starting amount, compute the total number of purchases possible before no credit and no exchange remain. Input Format: The first line contains t, the number of test cases. Each test case contains n. Output Format: For each test case, print the total number of purchases.

Examples

Example 1
Input:
1
10
Output:
11

Explanation: The first ten credits buy ten items and create ten receipts. Those receipts provide one extra credit, so the total becomes eleven purchases.

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.

solution.cpp