当前位置:网站首页>Mingming loves drinking water
Mingming loves drinking water
2022-07-19 06:54:00 【winkiii】
describe
Obviously, he is a water crazy devil , He went to the convenience store to buy n A bottle of water , Each bottle of water m element . It is known that 3 An empty bottle can be changed into a bottle of water ,7 A bottle cap can also be changed into a bottle of water . Beg Mingming to drink a few bottles of water at most ?
Output
The maximum number of bottles changed .
sample input 1
3 2
3 3
3 10
sample output 1
0
1
4
#include<stdio.h>
int ps(int eb,int pg,int p){
// Find the function of the number of bottles that can be replaced by empty bottles and bottle caps
if(eb<3&&pg<7){
// Two requirements are not met , Exit loop
return p;
}else{
return ps(eb/3+eb%3+pg/7,pg/7+pg%7+eb/3,eb/3+pg/7+p); // recursive
// The number of empty bottles that can be exchanged =3 Change an empty bottle 1 A bottle of water + Replace the empty bottle with more water + The water from the bottle cap
// The number of bottle caps that can be changed =7 A bottle cap for 1 A bottle of water + Change the bottle cap to get more water + Empty bottle of water
}
}
int main(){
int m,n;
int p;
while(scanf("%d%d",&m,&n)!=EOF){
if(m>n){
p = 0;
}
else if(m==n){
p = 1;
}
else{
p = ps(n/m,n/m,0); // The initial number of empty bottles and caps is n/m
}
printf("%d\n",n/m+p); // Buy water + Changed water
}
}
边栏推荐
- Wu Enda machine learning chapter 1-2
- Poor Xiaofan (simulation)
- 促进数字世界的信任
- 2022-7-15 cheap domestic PLC industrial control board with scattered records of 485 master-slave communication
- F5ltm (I) logic diagram
- 高并发day01(NIO、ConCurrent包)
- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
- X11 forwarding
- 基于Ardunio IDE软件开发编程学习
- 安全电子签章密码技术规范 GM/T 0031 | GB∕T 38540 格式OPENSSL封装解析
猜你喜欢

mysql的复习总结

Tcp/ip four layer model and related configurations of F5

用Altium Designer绘制PCB图

什么是数据中台?

Zuul路由的映射规则配置

Information on successful cooperation between CS brand sdnand and stm32mcu

2019cs brand sdnand and EMMC selection comparison important analysis

opensuse 安装网易云音乐(tumbleweed)(leap)

ssh远程登录服务

文本三剑客之awk命令--截取
随机推荐
ssh远程登录服务
阿里云、腾讯云、华为云、Ucloud(优刻得)、天翼云 的云服务器性能测试和价格对比
企业数据治理之勒索病毒篇
Information on successful cooperation between CS brand sdnand and stm32mcu
邮资范围(数组 or +函数)
Gentoo安装教程(Systemd+Gnome)
[jmeter] TCP Sampler
How can the new generation of CS sdnand (also known as patch T card) make the old MCU youthful
银河麒麟服务器系统搭建本地和局域网yum源
Loadng class `com. mysql. jdbc. Driver‘. This is deprecated. The new driver class is `com. mysql. cj. jdb
Personal information management system
Talk about Zhongtai: my understanding and thinking about Zhongtai
聊聊中台:我对中台的一些理解与思考
判断凹凸(数学题)
Comparison of advantages and disadvantages between SD NAND and EMMC
什么是数据中台?
Wu Enda machine learning chapter 14-15
关于STM汇编程序设计相关学习
Share the application cases of CS brand patch T card in the field of hunting camera
NAND nor flash flash flash product overview