PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000190. Mua thực phẩm và hoàn tiền (Food Buying)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Mua thực phẩm và hoàn tiền (Food Buying)
Food Buying
Source: Codeforces
Version: Phuoc Hung OJ (single-case adaptation where applicable)
Problem Statement
Mishka initially has units of money. On each purchase he may spend any integer between and his current balance; he then receives units of cashback. He may repeat purchases arbitrarily. Find the maximum total amount spent on purchases, including spending previously received cashback.
Input
The only line contains .
Output
Print the maximum total amount spent.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
19
Output
21
Explanation
Spend 10 and receive 1 cashback, leaving 10; spend 10 and receive 1 again, then spend the final 1. The total spent is 21.
Example 2
Input
10
Output
11
Explanation
Spending 10 earns 1 cashback, which can also be spent. Thus the maximum total is 11.