#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, k;
cout << "Enter Number of Piles : ";
cin >> n;
cout << "Enter At Most K Number : ";
cin >> k;
vector<int>p(n);
bitset<16>b[n];
cout << "Enter Number of Stone Each Pile : ";
for(int i=0; i<n; i++)
{
cin >> p[i];
bitset<16>a(p[i]);
b[i] = a;
}
bool flag = false;
for(int j=0; j<16; j++)
{
int sum = 0;
for(int i=0; i<n; i++)
{
if(b[i][j] == 1)
sum++;
}
sum = sum % (k+1);
if(sum > 0)
{
flag = true;
break;
}
}
if(flag == true)
cout << "First Player Win." << "\n";
else
cout << "Second Player Win." << "\n";
return 0;
}
Comments
Post a Comment