A11533 | Two Cakes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bought two cakes and cut them into pieces: the first cake has been cut into $a$ pieces, and the second one — into $b$ pieces.
Ivan knows that there will be $n$ people at the celebration (including himself), so Ivan has set $n$ plates for the cakes. Now he is thinking about how to distribute the cakes between the plates. Ivan wants to do it in such a way that all following conditions are met:
1. Each piece of each cake is put on some plate;
2. Each plate contains at least one piece of cake;
3. No plate contains pieces of both cakes.
To make his guests happy, Ivan wants to distribute the cakes in such a way that the minimum number of pieces on the plate is maximized. Formally, Ivan wants to know the maximum possible number $x$ such that he can distribute the cakes according to the aforementioned conditions, and each plate will contain at least $x$ pieces of cake.
Help Ivan to calculate this number $x$ !
Ivan knows that there will be $n$ people at the celebration (including himself), so Ivan has set $n$ plates for the cakes. Now he is thinking about how to distribute the cakes between the plates. Ivan wants to do it in such a way that all following conditions are met:
1. Each piece of each cake is put on some plate;
2. Each plate contains at least one piece of cake;
3. No plate contains pieces of both cakes.
To make his guests happy, Ivan wants to distribute the cakes in such a way that the minimum number of pieces on the plate is maximized. Formally, Ivan wants to know the maximum possible number $x$ such that he can distribute the cakes according to the aforementioned conditions, and each plate will contain at least $x$ pieces of cake.
Help Ivan to calculate this number $x$ !
输入格式
The first line contains three integers $n$ , $a$ and $b$ ( $1<=a,b<=100$ , $2<=n<=a+b$ ) — the number of plates, the number of pieces of the first cake, and the number of pieces of the second cake, respectively.
输出格式
Print the maximum possible number $x$ such that Ivan can distribute the cake in such a way that each plate will contain at least $x$ pieces of cake.
输入输出样例
输入 #1
5 2 3
输出 #1
1
输入 #2
4 7 10
输出 #2
3
In the first example there is only one way to distribute cakes to plates, all of them will have $1$ cake on it.
In the second example you can have two plates with $3$ and $4$ pieces of the first cake and two plates both with $5$ pieces of the second cake. Minimal number of pieces is $3$ .
In the second example you can have two plates with $3$ and $4$ pieces of the first cake and two plates both with $5$ pieces of the second cake. Minimal number of pieces is $3$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted