Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple:
The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones.
The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move.
The player who is unable to make a move loses.
Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game.
In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again.
Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally.
Input
First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles.
Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile.
Output
Print a single line containing “YES” (without quotes) if Jon wins, otherwise print “NO” (without quotes)
Examples
Input
Copy
1
5
Output
Copy
NO
Input
Copy
2
1
2
Output
Copy
YES
考虑sg 函数:
1,1,2,2,2,3,3,3,3…;
手算一下即可;
那么我们异或就好;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
#include<cctype>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 500005
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const int mod = 10000007;
#define Mod 20100403
#define sq(x) (x)*(x)
#define eps 1e-10
typedef pair<int, int> pii;
inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
}
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }
int sg[maxn];
int n;
int s[maxn];
void init() {
int cnt = 0;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= i; j++) {
sg[cnt] = i; cnt++;
}
}
}
int main()
{
//ios::sync_with_stdio(false);
rdint(n);
init();
int ans = 0;
for (int i = 0; i < n; i++) {
int x; rdint(x);
ans ^= sg[x];
}
if (ans)cout << "NO" << endl;
else cout << "YES" << endl;
}