Codeforces Round 770 (Div. 2)(数学异或奇偶性)

B. Fortune Telling
拿到题目看数据范围之后就知道暴力显然是来不及的。
那么只能找性质。
\(考虑x和x+3的不同 \quad 奇偶性不同\)
\(然后考虑两种操作对于一个数的奇偶性的影响\)
\(加法:同奇偶则运算结果是偶,不同则运算结果为奇\)
\(异或:惊奇的发现异或也是这样的\)
这样我们就把判断运算后是不是和y相同,转换为判断运算后是不是和奇偶性相同。
代码就很简单了

#include <bits/stdc++.h> 
#define int long long
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f 
#define x first
#define y second

using namespace std;

const int N=110,mod=1e9+7;


void solve()
{
	int n,x,y;cin>>n>>x>>y;
	rep(i,1,n)
	{
		int kk;cin>>kk;
		x^=kk;
	}
	if((x&1)==(y&1))	cout<<"Alice"<<endl;
	else	cout<<"Bob"<<endl;
}

signed main()
{
	IOS	
//  	freopen("1.in", "r", stdin);
  	int _;
	cin>>_;
	while(_--)
	solve();
	return 0;
}
posted @ 2024-02-01 19:53  cxy8  阅读(16)  评论(0)    收藏  举报