2019 GDUT Rating Contest I : Problem G. Back and Forth
题面:
G. Back and Forth
On Tuesday, he takes a bucket from the first barn, fills it, and carries the milk to the second barn, where he pours it into the storage tank. He leaves the bucket at the second barn.
On Wednesday, he takes a bucket from the second barn (possibly the one he left on Tuesday), fills it, and carries the milk to the first barn, where he pours it into the storage tank. He leaves the bucket at the first barn.
On Thursday, he takes a bucket from the first barn (possibly the one he left on Wednesday), fills it, and carries the milk to the second barn, where he pours it into the tank. He leaves the bucket at the second barn.
On Friday, he takes a bucket from the second barn (possibly the one he left on Tuesday or Thursday), fills it, and carries the milk to the first barn, where he pours it into the tank. He leaves the bucket at the first barn.
- 1000: FJ could carry the same bucket back and forth in each trip, leaving the total amount in the first barn’s tank unchanged.
- 1003: FJ could carry 2 units on Tuesday, then 5 units on Wednesday, then 1 unit on Thursday, and 1 unit on Friday.
- 1004: FJ could carry 1 unit on Tuesday, then 5 units on Wednesday, then 1 unit on Thursday, and 1 unit on Friday.
- 1007: FJ could carry 1 unit on Tuesday, then 5 units on Wednesday, then 2 units on Thursday, and 5 units on Friday.
- 1008: FJ could carry 1 unit on Tuesday, then 5 units on Wednesday, then 1 unit on Thursday, and 5 units on Friday.
题目描述:
题目分析:












1 #include <cstdio>
2 #include <iostream>
3 #include <set>
4 using namespace std;
5 const int maxn = 1e4;
6 int a[15], b[15];
7 set<int> ans;
8
9 int main(){
10 for(int i = 0; i < 10; i++) cin >> a[i];
11 for(int i = 0; i < 10; i++) cin >> b[i];
12
13 ans.insert(1000); //第一种情况
14 int d1, d2, t;
15 for(int i = 0; i < 10; i++){
16 for(int j = 0; j < 10; j++){
17 d1 = b[j]-a[i]; //差值
18
19 //交换桶
20 t = a[i];
21 a[i] = b[j];
22 b[j] = t;
23
24
25 for(int k = 0; k < 10; k++){
26 for(int p = 0; p < 10; p++){
27 d2 = b[p]-a[k]; //第二次不用交换, 直接算差值
28 ans.insert(1000+d1+d2); //第三种情况
29 }
30 }
31 ans.insert(1000+d1); //第二种情况
32
33 //换回来
34 t = a[i];
35 a[i] = b[j];
36 b[j] = t;
37
38 }
39 }
40
41 cout << ans.size() << endl;
42 return 0;
43 }
2019 GDUT Rating Contest I : Problem G. Back and Forth的更多相关文章
- 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 F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 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 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 H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 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 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 C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- Leetcode(11)-盛最多水的容器
给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) .画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0).找出其中的两条线,使得 ...
- volatile的内存屏障的坑
请看下面的代码并尝试猜测输出: 可能一看下面的代码你可能会放弃继续看了,但如果你想要彻底弄明白volatile,你需要耐心,下面的代码很简单! 在下面的代码中,我们定义了4个字段x,y,a和b,它们被 ...
- hihoCoder Challenge 3
#1065 : 全图传送 时间限制:30000ms 单点时限:3000ms 内存限制:256MB 描述 先知法里奥是 Dota 系列中的一个英雄.机动性强,推塔能力一流,打钱速度快,传送技能使先知可以 ...
- Apple Watch Series 6 字母图案 (图解教程)
Apple Watch Series 6 字母图案 (图解教程) Apple Watch Series 6 自定义文字 如何开启 字母图案 solution 1 选择 彩色 表盘️ PS: 该复杂功能 ...
- JWT All In One
JWT All In One OAuth 2.0 JWT JSON Web Tokens https://jwt.io refs https://www.cnblogs.com/xgqfrms/tag ...
- how to fetch a group promise api in order with the returned resolved result
how to fetch a group promise api in order with the returned resolved result promise 一组依次请求,generator ...
- PAUL ADAMS ARCHITECT:费城东北区的房地产市场逆势而行
根据Zillow.com的房产数据,大费城地区前三季度成交房产的平均价格为27.2万美元,较去年同期增长了13.4%,为10年同期最高.即使如此,27.2万的均价与纽约相比依然相距甚远,其中尤其是费城 ...
- go-admin在线开发平台学习-3[细节解析]
本章节主要的内容是对go-admin中的一些有趣编码进行分析,为自己以后提供一些借鉴 使用cli方式启动项目 使用cobra[眼镜蛇]完成强壮cli的工具,确保稳定. 使用cli的方式启动项目的好处显 ...
- CodeMirror动态修改代码(关键: editor.getDoc().setValue(data); editor.refresh();)
在使用codemirror时,其原理是根据form中的textarea标签,自动加载其内容,获得代码行的显示.(具体使用方式参见 codemirror官网使用手册 http://codemirror. ...
- lms微服务框架介绍
lms 框架简介 Lms是一个旨在通过.net平台快速构建微服务开发的框架.具有稳定.安全.高性能.易扩展.使用方便的特点.lms内部通过dotnetty实现高性能的rpc通信,使用zookeeper ...