码迷,mamicode.com
首页 > 其他好文 > 详细

CF1324A Yet Another Tetris Problem 题解

时间:2020-03-23 09:29:01      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:就是   code   题解   etc   技术   改变   another   space   不能   

原题链接

简要题意:

技术图片

再简要一波:

每次可以把一个数增加 \(2\),问最后能不能让所有数相等。(也就是抵消掉)

什么?题意变成这样子还做个啥?

你会发现,必须所有数的奇偶性都相同,才可以;反之就不可以。

这结论不用证明了,因为每次增加不会改变奇偶性的。

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;

inline int read(){char ch=getchar();int f=1;while(ch<‘0‘ || ch>‘9‘) {if(ch==‘-‘) f=-f; ch=getchar();}
	int x=0;while(ch>=‘0‘ && ch<=‘9‘) x=(x<<3)+(x<<1)+ch-‘0‘,ch=getchar();return x*f;}

int main(){
	int T=read(),n,p;
	while(T--) {
		n=read(),p=read(); bool f=0;
		for(int i=1,t;i<n;i++) {
			t=read();
			if((t&1) != (p&1)) f=1;
		} if(!f) puts("YES");
		else  puts("NO");
	}
	return 0;
}

CF1324A Yet Another Tetris Problem 题解

标签:就是   code   题解   etc   技术   改变   another   space   不能   

原文地址:https://www.cnblogs.com/bifanwen/p/12550057.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!