PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000305. Hoàn trả khoản vay sữa (Loan Repayment)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hoàn trả khoản vay sữa (Loan Repayment)
Loan Repayment
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
John owes Bessie units of milk, due within K days. He chooses a fixed positive integer X. Each day before the debt is repaid, if G units have already been paid, he pays . Repayment may stop once at least N has been paid. Given , find the largest X that repays the debt within K days.
Input
One line contains .
Output
Print the largest positive integer X.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Examples
Input 1
10 3 3
Output 1
2
Explanation
For X=2, payments are 5,3,3. For X=3, three payments of 3 are insufficient.