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

Bài tập thuộc lộ trình

1 lộ trình

Hoàn trả khoản vay sữa (Loan Repayment)

Loan Repayment

Source: USACO

Version: Phuoc Hung OJ Extended

Problem Statement

John owes Bessie NN 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 max⁡(M,⌊(N−G)/X⌋)\max(M,\lfloor(N-G)/X\rfloor). Repayment may stop once at least N has been paid. Given KM<NKM<N, find the largest X that repays the debt within K days.

Input

One line contains N,K,MN,K,M.

Output

Print the largest positive integer X.

Subtasks

  • Subtask 1 (20 points): 1≤N≤3001\le N\le300; 1≤K,M≤10121\le K,M\le10^{12}; KM<NKM<N.
  • Subtask 2 (30 points): 1≤N,K,M≤10121\le N,K,M\le10^{12}; K≤105K\le10^5; KM<NKM<N.
  • Subtask 3 (50 points): 1≤N,K,M≤10121\le N,K,M\le10^{12}; KM<NKM<N.

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.