The smallest number of banknotes (minbonds)
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
In Orlandia, there are only two types of banknotes in use: those worth k eagles and those worth r eagles. Your task is to help an Orlandian find the minimum number of banknotes required to make a payment of sum eagles. You need to specify how many banknotes of each denomination (k and r) are used.
Input
Provide the values k, r, and sum where (10 \leq k, r \leq 3 \times 10^6) and (10 \leq \text{sum} \leq 3 \times 10^9).
Output
Output the number of banknotes of the smaller denomination and the number of banknotes of the larger denomination, along with the total minimum number of banknotes used. If it is impossible to achieve the exact sum with the given denominations, output -1.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 528
Acceptance rate 12%