-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathsolution.cpp
More file actions
31 lines (30 loc) · 793 Bytes
/
Copy pathsolution.cpp
File metadata and controls
31 lines (30 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
This problem is identical to standard nim game.
If the current player is in winning position and the opponent adds some chips,
the current player can remove those chips in his move and remain in winning position.
As the current player can mirror his opponent's "add" move all the time, that move has no value.
Now you can find xor sum like standard nim game and determine who will win the game.
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int q;
cin>>q;
while(q--)
{
int n,k;
cin>>n>>k;
int ans=0;
int x;
for(int i=0;i<n;i++)
{
cin>>x; //input
ans^=x;
}
if(ans!=0)
cout<<"First\n";
else
cout<<"Second\n";
}
}