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 ...
随机推荐
- KEIL5 使用STM32 官方例程
1. 安装keil5,破解 网上很多安装包/教程,跳过 2.下载官方固件库 https://www.st.com/content/st_com/en.html 在这里找微处理器,STM32 stand ...
- 容器之List接口下各实现类(Vector,ArrayList 和LinkedList)的线程安全问题
Vector .ArrayList 和LinkedList都是List接口下的实现类,但是他们之间的区别和联系是什么呢? 首先: 然后: 如果您仅仅想知道结论,那么可以关闭了. 下面我讨论讨论为什么. ...
- HDU 4336 Card Collector(状压 + 概率DP 期望)题解
题意:每包干脆面可能开出卡或者什么都没有,一共n种卡,每种卡每包爆率pi,问收齐n种卡的期望 思路:期望求解公式为:$E(x) = \sum_{i=1}^{k}pi * xi + (1 - \sum_ ...
- Ubuntu16安装chrome
不免让您失望, 安装正常的chrome,Dependency is not satisfiable: libnss3 (>= 2:3.22)问题一直没能解决,故使用chromium次而代之. s ...
- YouTube 视频下载工具
YouTube 视频下载工具 我不生产视频,只是优秀视频的搬运工! YouTube-dl https://github.com/search?q=youtube-dl https://github.c ...
- Apple WWDC All In One
Apple WWDC All In One https://developer.apple.com/wwdc20/ https://developer.apple.com/videos/wwdc202 ...
- Mapbox 地图实验室
Mapbox 地图实验室 Learn with Mapbox https://www.mapbox.com/community/education/ https://labs.mapbox.com/e ...
- .NET 6 Preview 1 发布
前言 2021 年 2 月 17 日微软发布了 .NET 6 的 Preview 1 版本,那么来看看都有什么新特性和改进吧,由于内容太多了因此只介绍一些较为重点的项目. 统一和扩展 .NET 6 在 ...
- webpack + ts 配置路径别名无死角方法总结
webpack + ts 配置路径别名总结 自我体验加总结:在配置脚手架时,定制别名很有必要,可以使得代码更优雅,可读性更强.但在使用ts的时候,即便项目能够运行,vscode 确时长会提示 can' ...
- flask启动常见问题1:sqlalchemy.exc.ArgumentError: Mapper mapped class UserCode->data_system_user_email could not assemble any primary key columns for mapped table 'data_system_user_email'
我的描述:当我编辑好flask以后,ORM映射数据库完成,启动项目时,发生现象: 解决: 看字面的意思是主键导致的错误,于是我查看了data_system_user_email的键参数配置,发现表没有 ...