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 ...
随机推荐
- HDU - 4462 Scaring the Birds
It's harvest season now! Farmer John plants a lot of corn. There are many birds living around his co ...
- asp.net 从Excel表导入数据到数据库中
http://www.cnblogs.com/hfzsjz/archive/2010/12/31/1922901.html http://hi.baidu.com/ctguyg/item/ebc857 ...
- SVG tada 🎉 animation effects
SVG tada animation effects symbol & use <svg viewBox="0 0 80 20" xmlns="http:/ ...
- WiFi 测速
WiFi 测速 shit 联通 20M => 电信 20M ? https://zhuanlan.zhihu.com/p/86140645 shit 房东 中国电信网络测速 50M http:/ ...
- Redux React & Online Video Tutorials
Redux React & Online Video Tutorials https://scrimba.com/@xgqfrms https://scrimba.com/c/cEwvKNud ...
- css var all in one & html & root & :root
css var all in one number :root{ --num: 0; } html{ --num: 0; } let html = document.querySelector(`ht ...
- xcode upgrade & git bug
xcode upgrade & git bug ➜ op-static git checkout feature/select-seat-system Agreeing to the Xcod ...
- APC体育公司重视“女性经济 ”深度挖掘女性市场
据消费者追踪服务调查数据显示,从2020年1月到8月,a private company体育公司(公司编号:08703733)品牌下的女性运动服装的在线销售额较上一年增长了77%. 女性市场已然成为A ...
- Python学习笔记_斐波那契数列
""" 1.生成100项斐波那契数列 2.求第n项斐波那契数列的值是多少 3.给定终止值,生成此前斐波那契数列 """ # 求第n项斐波那契 ...
- Nifi组件脚本开发—ExecuteScript 使用指南(三)
上一篇:Nifi组件脚本开发-ExecuteScript 使用指南(二) Part 3 - 高级特征 本系列的前两篇文章涵盖了 flow file 的基本操作, 如读写属性和内容, 以及使用" ...