This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN=1e5+10;
ll a[MAXN],n,k,sum;
void solve()
{
while(sum>0&&k>0)
{
if(k==1)
{
cout<<sum%2;
return;
}
if(sum%2==1)
{
cout<<1;
return;
}
k/=2;
sum=0;
for(ll i=1;i<=n;i++)
{
a[i]/=2;
sum+=a[i];
}
if(k==1)
{
cout<<sum%2;
return;
}
if(sum%2==1)
{
cout<<1;
return;
}
}
cout<<0;
}
void read()
{
cin>>n>>k;
sum=0;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
sum+=a[i];
}
}
int main()
{
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll t;
cin>>t;
while(t--)
{
read();
solve();
}
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |