A839 | Loan Repayment--Silver
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Farmer John owes Bessie $N$ gallons of milk ($1\le N\le 10^{12}$). He has to
give her the milk within $K$ days. However, he doesn't want to give the milk
away too quickly. On the other hand, he has to make forward progress on the
loan, so he must give Bessie at least $M$ gallons of milk each day ($1\le M\le
10^{12}$).
Here is how Farmer John decides to pay back Bessie. He first picks a positive
integer $X$. He then repeats the following procedure every day:
1. Assuming that Farmer John has already given Bessie $G$ gallons, compute $\frac{N-G}{X}$ rounded down. Call this number $Y$.
2. If $Y$ is less than $M$, set $Y$ to $M$.
3. Give Bessie $Y$ gallons of milk.
Determine the largest $X$ such that if Farmer John follows the above
procedure, Farmer John gives Bessie at least $N$ gallons of milk after $K$
days ($1\le K\le 10^{12}$).
give her the milk within $K$ days. However, he doesn't want to give the milk
away too quickly. On the other hand, he has to make forward progress on the
loan, so he must give Bessie at least $M$ gallons of milk each day ($1\le M\le
10^{12}$).
Here is how Farmer John decides to pay back Bessie. He first picks a positive
integer $X$. He then repeats the following procedure every day:
1. Assuming that Farmer John has already given Bessie $G$ gallons, compute $\frac{N-G}{X}$ rounded down. Call this number $Y$.
2. If $Y$ is less than $M$, set $Y$ to $M$.
3. Give Bessie $Y$ gallons of milk.
Determine the largest $X$ such that if Farmer John follows the above
procedure, Farmer John gives Bessie at least $N$ gallons of milk after $K$
days ($1\le K\le 10^{12}$).
输入格式
The only line of input contains three space-separated positive integers $N$,
$K$, and $M$ satisfying $K\cdot M<N$.
$K$, and $M$ satisfying $K\cdot M<N$.
输出格式
Output the largest positive integer $X$ such that Farmer John will give Bessie
at least $N$ gallons using the above procedure.
at least $N$ gallons using the above procedure.
输入输出样例
输入 #1
10 3 3
输出 #1
2
* Test cases 2-4 satisfy $K\le 10^5.$
* Test cases 5-11 satisfy no additional constraints.
* Test cases 5-11 satisfy no additional constraints.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted