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 ...
随机推荐
- L3-002. 堆栈【主席树 or 线段树 or 分块】
L3-002. 堆栈 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 大家都知道"堆栈"是一种"先 ...
- js create Array ways All In One
js create Array ways All In One ES6 const arr = [...document.querySelectorAll(`[data-dom="^div& ...
- codepen 上25个最受欢迎的HTML/CSS代码
Codepen是一个非常了不起的网站,优设哥在设计师网址导航上也大力推荐过,得到了很多同学的喜爱,也是全球web前端开发人员的圣地! 我搜索了一些时下最好最流行的codepen(仅限于HTML和CSS ...
- ASCII Art
ASCII Art https://npms.io/search?q=ASCII art ASCII Art Text to ASCII Art Generator (TAAG) http://pat ...
- bob and brad physical therapy knee exercise
bob and brad physical therapy knee exercise 鲍勃和布拉德物理治疗膝关节运动 https://bobandbrad.com/ youtube https:// ...
- Jenkins Ansible GitLab 自动化部署
Jenkins Ansible GitLab 自动化部署 DevOps https://www.cnblogs.com/yangjianbo/articles/10393765.html https: ...
- Dart: 执行shell命令
1 创建包 >stagehand console-full 2 安装插件 process_run: ^0.10.1 3 编写 bin/main.dart ... import 'package: ...
- 千万不要错过VAST,NGK算力的下一个财富机会!
我们把目光投向NGK市场,近来,NGK接连新币,推出了SPC后,又有VAST.在目前市场上债券收益率已经趋近于零的情况下,世界上的大多数央行都在试图让本国货币贬值,所以在此时寻找其他保值资产是合理的. ...
- sql server 局域网与公网上的发布与订阅
一台局域网的服务器,可以访问公网. 一台云端的服务器. 要求:将局域网中的服务器部分数据库同步到云端的服务器上. 配置情况: win server 2012 是发布服务器. win server 20 ...
- ROS 安装完成后运行小乌龟示例程序
安装ROS成功后,在Beginner Tutorials中有一个简单的示例程序. 在Terminal中运行以下命令: $ roscore 新开一个terminal,运行以下命令,打开小乌龟窗口: $ ...