Easy20 pts
Halloween Sale
Buy video games with decreasing prices: first game costs p, each next costs d less, but price never goes below m. With budget s, how many games can you buy? Example: p=20, d=3, m=6, s=80 → Prices: 20, 17, 14, 11, 8, 6, 6... → Can buy: 20+17+14+11+8+6=76 → 6 games (can't afford 7th at 6)
Input
Four space-separated integers: p d m s
Output
A single integer: the number of games you can buy.
Sample
20 3 6 80
Expected
6
Loading editor…
Output
No output yet. Run your code to see results.