B. Two Cakes
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output
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 nplates 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:

Each piece of each cake is put on some plate;
Each plate contains at least one piece of cake;
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!

Input
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.

Output
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.

Examples
input
5 2 3
output
1
input
4 7 10
output
3
Note
In the first example there is only one way to distribute cakes to plates, all of them will have 1cake 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.

#include<bits/stdc++.h>
using namespace std;
int main(){
int n, a, b,ans;
while(cin>>n>>a>>b)
{
ans = ;
for(int i=;i<n;i++)
ans = max(min(a/i,b/(n-i)),ans);
cout<<ans<<endl;
}
return ;
}

[Codeforces-911B] - Two Cakes的更多相关文章

  1. Codeforces 629D Babaei and Birthday Cakes DP+线段树

    题目:http://codeforces.com/contest/629/problem/D 题意:有n个蛋糕要叠起来,能叠起来的条件是蛋糕的下标比前面的大并且体积也比前面的大,问能叠成的最大体积 思 ...

  2. Codeforces Round #542 B Two Cakes

    B. Two Cakes time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Codeforces Round #413 A. Carrot Cakes

    A. Carrot Cakes time limit per test   1 second memory limit per test   256 megabytes   In some game ...

  4. Educational Codeforces Round 35 B. Two Cakes【枚举/给盘子个数,两份蛋糕块数,最少需要在每个盘子放几块蛋糕保证所有蛋糕块都装下】

    B. Two Cakes time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. Codeforces Round #542(Div. 2) B.Two Cakes

    链接:https://codeforces.com/contest/1130/problem/B 题意: 给定n和 2 * n个数,表示i位置卖ai层蛋糕, 有两个人在1号,必须严格按照1-n的顺序买 ...

  6. 【codeforces 799A】Carrot Cakes

    [题目链接]:http://codeforces.com/contest/799/problem/A [题意] 你有一个烤炉; 每t秒能同时烤出k个蛋糕; 你可以在第一个烤炉在烤的时候;同时花费d秒建 ...

  7. 【Educational Codeforces Round 35 C】Two Cakes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直觉题. 感觉情况会很少. 毕竟间隔太大了.中间肯定有一些数字达不到. 有1肯定可以 2 2 x肯定可以 3 3 3也可以 2 4 ...

  8. 【Educational Codeforces Round 35 B】Two Cakes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 从小到大枚举x. 看看a/x+b/x是不是大于等于n 是的话. 看看是不是两种蛋糕都能凑一堆. 也即x的最大枚举量是min(a,b) ...

  9. Codeforces 834D The Bakery【dp+线段树维护+lazy】

    D. The Bakery time limit per test:2.5 seconds memory limit per test:256 megabytes input:standard inp ...

  10. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力,B.优先队列,C.dp乱搞)

    A. Carrot Cakes time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

随机推荐

  1. Java设计模式16:常用设计模式之观察者模式(行为型模式)

    1. Java之观察者模式(Observer Pattern) (1)概述: 生活中我们在使用新闻app,当我们对某一栏比较感兴趣,我们往往会订阅这栏新闻,比如我对军事栏感兴趣,我就会订阅军事栏的新闻 ...

  2. virtualbox+vagrant学习-3-Vagrant Share-2-HTTP Sharing

    HTTP Sharing Vagrant Share可以创建一个可公开访问的URL端点来访问在Vagrant环境中运行的HTTP服务器.这被称为“HTTP共享”,在使用Vagrant Share时默认 ...

  3. swoole_table测试

    public function test()    {        $count = [];        $count[] = ['key' => 'name', 'type' => ...

  4. 初识Qt文件下载

    1.新建一个Qt Gui应用,项目名称为http,基类选择为QMainWindow,类名设置为MainWindow. 2.在http.pro文件中的QT  += core gui后添加\ networ ...

  5. 【题解】洛谷P1070 道路游戏(线性DP)

    次元传送门:洛谷P1070 思路 一开始以为要用什么玄学优化 没想到O3就可以过了 我们只需要设f[i]为到时间i时的最多金币 需要倒着推回去 即当前值可以从某个点来 那么状态转移方程为: f[i]= ...

  6. P1437 [HNOI2004]敲砖块

    题目描述 在一个凹槽中放置了 n 层砖块.最上面的一层有n 块砖,从上到下每层依次减少一块砖.每块砖 都有一个分值,敲掉这块砖就能得到相应的分值,如下图所示. 14 15 4 3 23 33 33 7 ...

  7. 学习scalaenv

    背景 最近由于工作需要, 我总是在不同的scala项目间流动开发. 这就遇到一个很棘手的问题, 这几个项目用的scala版本不一致, 老项目用的是 scala 2.11.8, 新项目用的是 scala ...

  8. 接口与协议学习笔记-USB协议_USB2.0_USB3.0不同版本(三)

    USB(Universal Serial Bus)全称通用串口总线,USB为解决即插即用需求而诞生,支持热插拔.USB协议版本有USB1.0.USB1.1.USB2.0.USB3.1等,USB2.0目 ...

  9. JavaWeb基础—Http协议

    一.什么是Http协议 超文本传输协议的简称,用于定义客户端与web服务器通迅的格式. 关于[标准的HTTP协议是无状态的],请参见:http://www.cnblogs.com/bellkosmos ...

  10. Oracle中用户解锁

    以hr 用户为例: SQL> alter user hr account unlock; ユーザーが変更されました. SQL> alter user hr identified by hr ...