— antontrygubO_o
Your friends Alice and Bob practice fortune telling.
Fortune telling is performed as follows. There is a well-known array aa of nn non-negative integers indexed from 11 to nn. The tellee starts with some non-negative number dd and performs one of the two operations for each i=1,2,…,ni=1,2,…,n, in the increasing order of ii. The possible operations are:
- replace their current number dd with d+aid+ai
- replace their current number dd with d⊕aid⊕ai (hereinafter ⊕⊕ denotes the bitwise XOR operation)
Notice that the chosen operation may be different for different ii and for different tellees.
One time, Alice decided to start with d=xd=x and Bob started with d=x+3d=x+3. Each of them performed fortune telling and got a particular number in the end. Notice that the friends chose operations independently of each other, that is, they could apply different operations for the same ii.
You learnt that either Alice or Bob ended up with number yy in the end, but you don't know whose of the two it was. Given the numbers Alice and Bob started with and yy, find out who (Alice or Bob) could get the number yy after performing the operations. It is guaranteed that on the jury tests, exactly one of your friends could have actually gotten that number.
Hacks
You cannot make hacks in this problem.
Input
On the first line of the input, you are given one number tt (1≤t≤1041≤t≤104) — the number of test cases. The following 2⋅t2⋅t lines contain test cases.
The first line of each test case contains three numbers nn, xx, yy (1≤n≤1051≤n≤105, 0≤x≤1090≤x≤109, 0≤y≤10150≤y≤1015) — the length of array aa, Alice's initial number (Bob's initial number is therefore x+3x+3), and the number that one of the two friends got in the end.
The second line of each test case contains nn numbers — the array aa (0≤ai≤1090≤ai≤109).
It is guaranteed that the sum of nn over all test cases does not exceed 105105.
Output
For each test case, print the name of the friend who could get the number yy: "Alice" or "Bob".
Example
input
Copy
4 1 7 9 2 2 0 2 1 3 4 0 1 1 2 3 4 2 1000000000 3000000000 1000000000 1000000000
output
Copy
Alice Alice Bob Alice
Note
In the first test case, Alice could get 99 using the following operations: 7+2=97+2=9.
In the second test case, Alice could get 22 using this operations: (0+1)⊕3=2(0+1)⊕3=2.
In the third test case, Bob started with x+3=0+3=3x+3=0+3=3 and could get 11 this way: (((3+1)+2)⊕3)⊕4=1(((3+1)+2)⊕3)⊕4=1.
思路:异或与加法混合:异或又叫不进位加法,运算的值:异或与加法相同的地方是第一位(二进制):因为不用考虑进位。题上说让 Alice 从0开始,Bob 从3开始,很明显与奇偶性有关,说明与最后一位有关。CF会经常考奇偶性。那么最后的数(包括得到的数)的奇偶性就与开始的奇偶相关了:(相加)奇数个奇数得到的就是奇数,偶数个奇数就是偶数。
完整代码:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
//#define int long long
#define fir first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define repd(i, l, r) for (int i = l; i >= r; --i)
#define pb push_back
//#define mint modint<(int)1e9 + 7>
#define defop(type, op) \
inline friend type operator op (type u, const type& v) { return u op ##= v; } \
type& operator op##=(const type& o)
template<int mod>
struct modint {
int x;
// note that there is no correction, simply for speed
modint(int xx = 0): x(xx) {}
modint(ll xx): x(int(xx % mod)) {}
defop(modint, +) {
if ((x += o.x) >= mod) x -= mod;
return *this;
}
defop(modint, -) {
if ((x -= o.x) < 0) x += mod;
return *this;
}
defop(modint, * ) { return *this = modint(1ll * x * o.x); }
modint pow(ll exp) const {
modint ans = 1, base = *this;
for (; exp > 0; exp >>= 1, base *= base)
if (exp & 1) ans *= base;
return ans;
}
defop(modint, /) { return *this *= o.pow(mod - 2); }
};
//using mint = modint<(int)1e9 + 7>;
typedef modint<(int)1e9 + 7> mint;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--)
{
ll n,x,y;
cin>>n>>x>>y;
int sum=0;int a;
rep(i,1,n)
{
cin>>a;
if(a&1)sum++;
}
if(y&1)sum++;
if(x&1)
{
if(sum&1)cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
else
{
if(sum&1)cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
}
return 0;
}