2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面:
H. Mixing Milk
To mix the three different milks, he takes three buckets containing milk from the three cows. The buckets may have different sizes, and may not be completely full. He then pours bucket 1 into bucket 2, then bucket 2 into bucket 3, then bucket 3 into bucket 1, then bucket 1 into bucket 2, and so on in a cyclic fashion, for a total of 100 pour operations (so the 100th pour would be from bucket 1 into bucket 2). When Farmer John pours from bucket a into bucket b, he pours as much milk as possible until either bucket a becomes empty or bucket b becomes full.
- Pour 1->2: 0 7 5
- Pour 2->3: 0 0 12
- Pour 3->1: 10 0 2
- Pour 1->2: 0 10 2
- Pour 2->3: 0 0 12
题目描述:
题目分析:


1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 using namespace std;
5 int capa[5], leave[5];
6
7 void pour(int a, int b){
8 if(leave[a]+leave[b] <= capa[b]){ //第一种情况
9 leave[b] += leave[a];
10 leave[a] = 0;
11 }
12 else{ //第二种情况
13 leave[a] -= capa[b]-leave[b];
14 leave[b] = capa[b];
15 }
16 }
17
18 int main(){
19 for(int i = 1; i <= 3; i++){
20 cin >> capa[i] >> leave[i];
21 }
22
23 for(int i = 0; i < 33; i++){
24 pour(1, 2); //桶1倒进桶2
25 pour(2, 3); //桶2倒进桶3
26 pour(3, 1); //桶3倒进桶1
27 }
28
29 pour(1, 2); //最后别忘这个
30
31 for(int i = 1; i <= 3; i++){
32 cout << leave[i] << endl;
33 }
34 return 0;
35 }
2019 GDUT Rating Contest I : Problem H. Mixing Milk的更多相关文章
- 2019 GDUT Rating Contest II : Problem F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 2019 GDUT Rating Contest I : Problem A. The Bucket List
题面: A. The Bucket List Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest III : Problem A. Out of Sorts
题面: 传送门 A. Out of Sorts Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- windows 命令行 cmd 控制exe程序输入输出并比较
参考 https://www.cnblogs.com/zccz14/p/4588634.html 例子: 对exe输入输出 使用fc比较不同
- 牛客多校第九场 && ZOJ3774 The power of Fibonacci(二次剩余定理+斐波那契数列通项/循环节)题解
题意1.1: 求\(\sum_{i=1}^n Fib^m\mod 1e9+9\),\(n\in[1, 1e9], m\in[1, 1e4]\) 思路1.1 我们首先需要知道斐波那契数列的通项是:\(F ...
- CVE-2019-13272:Linux本地内核提权漏洞复现
0x00 简介 2019年07月20日,Linux正式修复了一个本地内核提权漏洞.通过此漏洞,攻击者可将普通权限用户提升为Root权限. 0x01 漏洞概述 当调用PTRACE_TRACEME时,pt ...
- 未来,Baccarat将如何拓展生态版图?
Baccarat最近几度冲上DeFi版面的热搜,一是因为BGV价格不断的上涨,二是因为生态建设者的不断涌入.可以说,当下的Baccarat,实在是太火爆了.那么在未来,Baccarat还将会持续火爆吗 ...
- PBN离场定高转弯保护区插件发布测试
昨天2月29日,是四年才有一次的日子,本想着应该写点什么,但一测试发现还有问题,只能先放下. 今天是三月份的第一天,一年已经过去了六分之一.疫情的关系,原本并不紧急的工作,现在也开始积压的有些多了,时 ...
- Hive底层原理:explain执行计划详解
不懂hive中的explain,说明hive还没入门,学会explain,能够给我们工作中使用hive带来极大的便利! 理论 本节将介绍 explain 的用法及参数介绍 HIVE提供了EXPLAIN ...
- Java 12 新特性介绍,快来补一补
Java 12 早在 2019 年 3 月 19 日发布,它不是一个长久支持(LTS)版本.在这之前我们已经介绍过其他版本的新特性,如果需要可以点击下面的链接进行阅读. Java 11 新特性介绍 J ...
- 微信小程序:block标签
代码中存在block标签,但是渲染的时候会移除掉. 例子: 如果将view改为block: 当你要渲染某些数据时,如果不想额外的加一层外边的标签,此时可以使用block标签来进行占位.
- MapString转Map
当把map使用toString方法转换后,如何再转换为map对象呢?方法很简单,把字符串进行截取,依次存放到新的map中: public static Map<String,Object> ...
- 开发在线教育平台项目步骤(Python3.7.6 + Django 3.0)
1. 新建虚拟环境 mkvirtualenv eduonline 2. 安装mysql数据库 pip install mysqlclient pip install pymysql 3. 在setti ...