Two Cakes

phaser3适配微信小游戏 阅读详情

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:

  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!

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

要是每个盘子中块数最少的盘子中的蛋糕最大化,肯定要平均分,然后枚举每种蛋糕平均分几个盘即可

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int n,a,b;
    while(~scanf("%d%d%d",&n,&a,&b)){
        int ans = 0;
        if(n == a+b)
            ans = 1;
        else{
            int i;
            for(i = 1; i < n; i++){
                int tmp1 = a/i;
                int tmp2 = b/(n-i);
                ans = max(ans,min(tmp1,tmp2));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}



华为OD机试 - 城市聚集度(Python/JS/C/C++ 2025 A卷 200分) 华为OD机试 2025A卷题库疯狂收录中,刷题。 阅读详情

相关推荐

QT与Coin3D实现机器人的仿真

前言 Coin3D编程环境配置好后,开始下一步的机器人仿真任务。本文根据在研5轴机器人,完成三维模型生成与机器人的仿真。主要参考博主冯Jungle的博客,在此表示感谢。 ——2021.05.23 环境 Win10:VS2019、QT5.15.2、Coin3D、SolidWorks2016 机器人三维模型生成 目前广泛应用于因特网的VRML ( Virtual Reality Modeling Language,虚拟现实建模语言)为用户提供一种可参与的、并能对场景中对象主动做出反应的虚拟现实环境,现已成

焦露的博客 6906

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

码农的一亩三分地 1274

104报文解析工具

可选择包含报文的文本文件或日志文件进行解析,可选择按条数范围或时间范围,输出结果可以在报文解析显示区,也可以输出到文件。可以对文本内容的报文文件进行高级分析,包括遥信遥测等通讯数据的具体信息,通讯帧的统计,通讯次数的统计,各种错误的分析,报文的定位功能,传输的文件具体内容等。输入完成后点击工具栏的解析报文按钮或使用右键菜单的解析就可以对报文进行解析。在报文输入区输入待解析报文并解析后,解析结果就显示在报文解析显示区和报文定位展示区及报文定位条目区。当有多条报文解析后,可以通过报文列表树具体定位某条报文。

XZHOUMIN的博客 5947

B. Two Cakes

Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 题意:两个人都从最左边出发,对于每个人来说都要拿够从 1 - n 的每个数,相邻两个数距离是 1,问最小花费步数可以让两个人全部拿够。 &amp;:排序,依次选取就可以。 #include&lt;bits/stdc++.h&gt; using namespace ...

Mercury_Lc的博客 660

Unity地形数据高效转换:从Terrain到3DMAX的OBJ导出实战

本文详细解析了Unity地形数据无法直接导入3DMAX的原因,并提供了高效转换的实战方案。通过编写自定义编辑器脚本,将Unity Terrain的高度图数据“烘焙”为静态网格模型,并以OBJ格式导出。文章重点讲解了核心代码逻辑、分辨率选择对模型精度的影响,以及在3DMAX中导入和优化模型的实用技巧,旨在打通Unity与3DMAX之间的数据协作壁垒。

sky77的博客 447

死区补偿---学习笔记

最近调试中发现,死区补偿对电流谐波和电流带宽影响挺大,于是对死区补偿产生浓厚兴趣,找来几篇文章粗读并做一下笔记。 传统做法 无非就是根据电流方向补偿,假如svpwm计算出的A相理论导通实践为T1,死区时间是Td,则实际导通时间T = T1-Td(when ia >0 ),于是在svpwm计算出的导通时间T1的基础上加上Td。这样经过PWM模块后,实际的导通时间即为T1. 但存在两个难点(个人总结): 1,受电流检测精度影响,尤其是在过零点检测困难。 2,真实的二极管导通需要一定电压,并非..

圆桌骑士的博客 2万+

911B - Two Cakes

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

memory_qianxiao的博客 888

不止是打字机效果:手把手教你用SpannableStringBuilder打造Android富文本AI对话界面

本文详细介绍了如何使用SpannableStringBuilder在Android平台上构建专业级AI对话界面,涵盖流式文本处理、富文本解析、交互优化等核心技术。通过实战代码示例,帮助开发者实现类似DeepSeek的AI产品交互效果,提升用户体验和应用专业度。

weixin_28358083的博客 197

CodeForces - 912B. New Year's Eve

B. New Year's Evetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSince Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz...

不会就选B的博客 520

Power EM与Signal EM解决办法与原理分析

1.面对power EM,首先检查missing via,补全via,还可以加宽,加密局部power mesh,一些power IO出pin有power EM问题,可以叠加多层线和垂直方向补power形成网络降低并联电阻和提供更多电流通路解决,这种方法还可以降低ir drop。3.先进工艺有一个via ladder的方法可以解决power/signal em问题,clock cell出pin绕线或者power rail连接power stripe通过搭梯子的方式连接,原理还是分流。

m0_61544122的博客 4740

第二节:Vben Admin 登录逻辑梳理和对接后端准备

第一节,我们已经配置了前端环境,运行起来了我们的Vben Admin的项目。本节内容,我们先熟悉下项目的目录和文件,然后开始准备对接后端程序路由在 src/router页面在 sr/views本节前端登录逻辑梳理完成了,后端只要在/api/login 接口编写返回逻辑,前后段就可以打通了,具体详情我们下一节介绍。

cuiwin的专栏 5084

CF 1130B Two Cakes

B. Two Cakes time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n differe...

浮生匆忙,与君同往 752

YOLO11改进|卷积篇|引入SPDConv

YOLO11中添加SPDConv卷积

A1983Z的博客 3696

codeforce B. Two Cakes

题意: 两个人从左边第一个位置出发,从小到大依次取得1到n,问做过的最短距离是多少。 思路: 贪心问题。因为我们很容易分析到,当一个人走到一个数字之后,他会向下一个数字走去,但是有两个位置,他就要选择一个。这里我们考虑的是,两个人较小位置的应该走向下一个数的较小位置,较大位置的应该走向下一个数的较大位置,这样的每一步两个人都是最短距离,最后的路线和也是最短的。 代码: #include<bi...

小飞猪的博客 256

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

[Codeforces-911B] - Two Cakes

[Codeforces-911B] - Two Cakes B. Two Cakestime limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard outputIt's New Year's Eve soon, so...

WBA 446

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

【BZOJ3072】[Pa2012]Two Cakes【DP】

【题目链接】 题解: 很容易想到O(n^2)DP的做法。 (1)A[i] == B[j],dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1 (2)A[i] != B[j],dp[i][j] = dp[i - t + 1][j - t + 1] + t,t表示最长的一段不相等的数的长度 发现如果连续的一段内要填写的两个数都不相同,那么一定是贪

BraketBN 1352

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

[bzoj3072]Two Cakes

题目描述有两个长度为n的排列(1<=n<=1,000,000),然后你要再次写出一模一样的两个排列,于是你的左手和右手同时拿笔开始写。但是为了锻炼自己的协调能力,你不想左手和右手同时在写一模一样的数,每写一个数你就需要花1ms的时间,那么你要写完这两个序列至少要花多久时间呢?注:每个序列同时只准用一只手写。DP要注意到这是两个排列。。 最朴素的dp是设dp[i,j] 如果a[i]!=b[j],肯

不来也不去的一只失忆蝴蝶 703

贪心 F - Two Cakes

题目 Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top ...

qq_45891413的博客 275

codeforces 1130B. Two Cakes

题目链接:http://codeforces.com/contest/1130/problem/B 题目分析 感觉之前在哪里写过这个题,有点像洛谷的 P1007 独木桥 (链接:https://www.luogu.org/problemnew/show/P1007) 由于两个人都需要实现同样的目的,而且情况一致,那么我们将这两个人当作一个整体,先让这个整...

天际苍穹的博客 450

[CF911B]Two Cakes

题目大意:   有两种蛋糕,分别被切成了a块和b块,要把这些蛋糕分到n个盘子里。   要求每个盘子里只能有一种蛋糕,每一种蛋糕都被分。问最优情况下,盘子里至少能放几个蛋糕。 思路:   二分答案。   由于每个蛋糕都要被分,所以二分的上界是min(a,b)而不是a+b。   然后O(n)检验即可。 1 #include<cstdio> 2 #include...

weixin_34185560的博客 249

3072: [Pa2012]Two Cakes

有dp[i][j]=min(d[i-1][j],d[i][j-1])+1 –> a[i]==b[j] dp[i][j]=d[i-t+1][j-t+1]+t —> t为i,j向前最长的不同序列; 但真正需要记录的状态为O(n);#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=n;i++) using namespace std;

limboman的博客 437

Codeforces Round #542 B Two Cakes

B. Two Cakes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sasha and Dima want to buy two nn -tier cakes. Each cak...

weixin_30546933的博客 195

【Educational Codeforces Round 35 C】Two Cakes

【链接】 我是链接,点我呀:) 【题意】 在这里输入题意 【题解】 直觉题。 感觉情况会很少。 毕竟间隔太大了。中间肯定有一些数字达不到。 有1肯定可以 2 2 x肯定可以 3 3 3也可以 2 4 4也可以。 就这样 【代码】 #include <bits/stdc++.h> using namespace std; vector <int&gt...

137
上一篇: New Year and Buggy Bot
下一篇: Mike and Chocolate Thieves CodeForces - 689C (二分思想)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值