A.Card Game

题目大意:两个人都有共有n张卡牌,每张卡牌上都有一个数xi,没有两张牌上的数相同,且xi不小于1不大于n。每次两个人选出一张牌来,牌上数字大的人赢得此局,如果谁最后手上拥有所有的n张牌,那么他取得胜利。

分析:只要判断数字为n的牌在谁的手里即可。

代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,k1,k2,x;
cin>>t;
while(t--){
cin>>n>>k1>>k2;
int f = ;
for(int i=;i<k1;i++){
cin>>x;
if(x==n) f=;
}
for(int i=;i<k2;i++){
cin>>x;
if(x==n) f=;
}
if(f==) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}

B.Interesting Subarray

题目大意:问你是否能找到一个连续子序列,使得这段子序列里最大值减最小值大于等于这段子序列的长度。

分析:只用比较相邻的两个数即可。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+;
int a[maxn];
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
for (int i = ; i <= n; i++)
cin >> a[i];
bool f = false;
int l = -, r = -;
for (int i = ; i <= n - ; i++) {
if (abs(a[i] - a[i + ]) >= ) {
f = true;
l = i;
r = i + ;
}
}
if (f) {
cout << "YES" << endl;
cout << l << " " << r << endl;
} else {
cout << "NO" << endl;
}
}
return ;
}

C. Make Good

题目大意:让你再找几个ai,使得a1+a2+...+an=2*(a1^a2^...^an)。

分析:就直接构造一个最简单的方法出来就行了,因为添加的元素个数没有限制到最少。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
typedef long long ll;
ll a[maxn];
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
for (int i = ; i <= n; i++)
cin >> a[i];
ll l = a[], r = a[];
for (int i = ; i <= n; i++) {
l += a[i];
r ^= a[i];
}
//l+x/2 = 2*(r^x) 2*l+x=4*(r^x)
//1/2*l+x/4 = r^x
cout << << endl;
cout << r << " " << l + r << endl;
}
return ;
}

Good Bye 2019的更多相关文章

  1. Good Bye 2019(前五题题解)

    这套也是后来补得. 我太菜了,第三题就卡着了.想了好久才做出来,要是参加了绝对掉分. D题是人生中做完的第一道交互题,不容易. 比赛传送门 A.Card Game 题目大意:一共有n张互不相同的牌,玩 ...

  2. [题解][Codeforces]Good Bye 2019 简要题解

    构造题好评,虽然这把崩了 原题解 A 题意 二人游戏,一个人有 \(k_1\) 张牌,另一个人 \(k_2\) 张,满足 \(2\le k_1+k_2=n\le 100\),每张牌上有一个数,保证所有 ...

  3. byteCTF 2019

    本文作者:z3r0yu  由“合天智汇”公众号首发,未经允许,禁止转载! 0x00 前言 周末的比赛质量还是挺高的,特别是boring_code,有点烧脑但是做的就很开心. 0x01 boring_c ...

  4. 2019年台积电进军AR芯片,将用于下一代iPhone

    近日,有报道表示台积电10nm 芯片可怜的收益率可能会对 2017 年多款高端移动设备的推出产生较大的影响,其中自然包括下一代 iPhone 和 iPad 机型.不过,台积电正式驳斥了这一说法,表明1 ...

  5. Good Bye 2013 A

    A. New Year Candles time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. VS经常报错的link error 2019

    VS经常报错的link error 2019 原因如下: 可能是找得到头文件,但是相关的dll或者lib找不到,需要在配置里面添加相应的库文件. project=>configuration.. ...

  7. YTU 2019: 鞍点计算

    2019: 鞍点计算 时间限制: 1 Sec  内存限制: 64 MB 提交: 66  解决: 30 题目描述 找出具有m行n列二维数组Array的"鞍点",即该位置上的元素在该行 ...

  8. codeforces Gym 100500 J. Bye Bye Russia

    Problem J. Bye Bye RussiaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1005 ...

  9. Windows Server 2019 预览版介绍

    在Windows server 2012.Windows server 2016还未完全普及的情况下,昨天Windows Server团队宣布Windows Server 2019将在2018年的下半 ...

随机推荐

  1. checkbox全选/取消全选

    //checkbox全选/取消全选 $(function() { $("#checkAll").click(function() { if(this.checked){ $(&qu ...

  2. Linux centosVMware mysql用户管理、常用sql语句、mysql数据库备份恢复

    一.mysql用户管理 grant all on *.* to 'user1'@‘127.0.0.1’ identified by 'mimA123'; 创建user1用户 使用user1登录 /us ...

  3. redhat 7.6 find 命令

    1.按名字查找 find  ./    -name  filename    //精确查找 ,./ 代表当前目录   -name 查询名称 filename具体文件名称 find  ./    -na ...

  4. Centos7 安装编译nginx-1.9.6过程

    一.安装环境准备 使用编译安装nginx最好都先安装下这些依赖包 安装nginx需要的依赖库 yum install -y gcc patch libffi-devel python-devel zl ...

  5. Py西游攻关之基础数据类型(三)-元组

    Py西游攻关之基础数据类型 - Yuan先生 https://www.cnblogs.com/yuanchenqi/articles/5782764.html 六 tuple(元组) 元组被称为只读列 ...

  6. 117、Java中String类之去掉左右空格

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  7. linux----Nginx能做什么

    linux----Nginx能做什么 标签: nginx负载均衡代理服务器 2017-04-01 14:15 588人阅读 评论(0) 收藏 举报 .embody{ padding:10px 10px ...

  8. freeswitch install

    https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7+and+RHEL+7

  9. cookie、sessionStorage和localStorage的区别

    cookie.sessionStorage.localStorage 都是用于本地存储的技术:其中 cookie 出现最早,但是存储容量较小,仅有4KB:sessionStorage.localSto ...

  10. JavaScript内置对象Array、String 的方法

    Array push() //将一个或多个数据加入到数组的末端,并返回新的数组长度. pop() //取出数组中的最后一项,修改length属性,并返回被删除的数据 shift() //取出数组中的第 ...