Chocolate Feast
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Runs in your browser
- Before starting
- Use a supported browser; initial dependencies may need internet.
- What it proves
- Run shows output; Test checks the authored cases, not every possible input.
- When finished
- Stop active runs when finished. No cloud infrastructure is provisioned by this exercise.
LEARN BY DOINGPut your intuition to work3 steps
Chocolate Feast
Use the lesson’s examples and explanation to check your idea.
Personal reflection. Nothing is sent to an AI service.Before you start
Browser lesson checks; review each requirement in Tests.
Catalog level: Easy · Estimated time: 15 min. Your prior experience can change the difficulty.
Sample case — your program reads stdin and prints to stdout.
Need a hand?
Start with a small test case. Hints progress from an idea to an explanation and, when requested, code.
Starter Bobby has n dollars. Each chocolate costs c. For every m wrappers, exchange for 1 free chocolate. Calculate total chocolates eaten.
Example: n=10, c=2, m=5 → Buy 5 chocolates (10/2) → 5 wrappers → Exchange for 1 more → Eat it → 1 wrapper left → Total: 6 chocolates
Input format
First line: t (test cases). Next t lines: n c m (space-separated).
Output format
For each test case, output the total number of chocolates.
Constraints
1 ≤ t ≤ 1000, 2 ≤ n ≤ 10⁵, 1 ≤ c ≤ n, 2 ≤ m ≤ n