이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |