Two Cakes
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:
- 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.
Example
5 2 3
1
4 7 10
3
Note
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.
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
int n,a,b,m = ;
cin>>n>>a>>b;
for(int i = ;i < n;i ++)
{
int d = min(a/i,b/(n - i));
if(d > m)m = d;
}
cout<<m;
}
Two Cakes的更多相关文章
- hdu 5997 rausen loves cakes(线段数合并+启发式修改)
题目链接:hdu 5997 rausen loves cakes 题意: 给你n个点,每个点有一个颜色,现在有两个操作,第一个操作,将颜色x改为颜色y,第二个操作,询问[x,y]区间有多少颜色段(颜色 ...
- BZOJ3498PA2009 Cakes——三元环
题目描述 N个点m条边,每个点有一个点权a.对于任意一个三元环(j,j,k)(i<j<k),它的贡献为max(ai,aj,ak) 求所有三元环的贡献和.N<100000,,m< ...
- 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 ...
- [BZOJ 3498] [PA 2009] Cakes
Description \(n\) 个点 \(m\) 条边,每个点有一个点权 \(a_i\). 对于任意一个三元环 \((i,j,k)(i<j<k)\),它的贡献为 \(\max(a_i, ...
- [Codeforces-911B] - Two Cakes
B. Two Cakestime limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutpu ...
- Codeforces Round #413 A. Carrot Cakes
A. Carrot Cakes time limit per test 1 second memory limit per test 256 megabytes In some game ...
- 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 ...
- HDU 5997 rausen loves cakes(启发式合并 + 树状数组统计答案)
题目链接 rausen loves cakes 题意 给出一个序列和若干次修改和查询.修改为把序列中所有颜色为$x$的修改为$y$, 查询为询问当前$[x, y]$对应的区间中有多少连续颜色段. ...
- BZOJ3072 : [Pa2012]Two Cakes
考虑DP,设$f[i][j]$表示考虑了$a[1..i]$和$b[1..j]$的最小代价. 若$a[i]==b[j]$,则$f[i][j]=\min(f[i-1][j],f[i][j-1])+1$. ...
随机推荐
- Java底层代码实现单文件读取和写入(解决中文乱码问题)
需求: 将"E:/data/车站一次/阿坝藏族羌族自治州.csv"文件中的内容读取,写入到"E:/data//车站一次.csv". 代码: public cla ...
- “中兴捧月”比赛之——二叉查找树(BST)树的最短路径Java求解
问题描述: BST树,又称二叉查找树,求其到所有叶子节点路径的最小值 测试用例一: 10 5 20 返回15: 测试用例二: 100 20 70 110 120 10 null null 89 nu ...
- dll和lib
lib:里面包含了很多源代码,工程会将这些源代码加入自己的项目中编译: dll:动态编译库,允许可执行文件在运行中加载里面的资源. 使用lib需注意两个文件:(1).h头文件,包含lib中说明输出的类 ...
- 一言(ヒトコト)Hitokoto API
『想要成为无论多么悲伤的时候,也能够漂亮微笑的人吧.』 Hitokoto API 更新:2014.02.22 问题/反馈:api # hitokoto.us 数据获取:[ 数据获取 ] 调用举例:[ ...
- python机器学习——分词
使用jieba库进行分词 安装jieba就不说了,自行百度! import jieba 将标题分词,并转为list seg_list = list(jieba.cut(result.get(" ...
- 经典的MapReduce1解析
MapReduce1任务图解 最顶层包含4个独立的实体客户端,提交MapReduce作业jobtracker,协调作业的运行.Jobtracker是一个Java应用程序,它的主类是JobTracker ...
- @RequestMapping
可以设定访问的目录,与访问的方式 对象可以是类,也可以是方法 @RequestMapping(value = "/say",method = RequestMethod.GET) ...
- 用intellij idea 写第一个Java程序
Java小白,还不怎么会eclipse,只会在命令行用javac编译并java运行编译后的类. 英文还不好orz 发现创建项目后,能build但就是不能run... 找了半天教程没找着,去官网溜了一下 ...
- VC++异常捕获??
1. std: #include <string> #include<iostream> // for cerr //#include <stdexcept> // ...
- cell 配置
Cells Cell configuration options Configure the API (top-level) cell Configure the child cells Config ...