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>
using namespace std;
int e2 (int k) {
int p = (int)log2(k);
return (int)pow(2, p);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t, n, k, mov, total;
vector<int> v;
cin >> t;
while (t--) {
cin >> n >> k;
total = mov = 0;
v.assign(n, 0);
for (int i = 0; i < n; i++) {
cin >> v[i];
total += v[i];
}
if (total % 2 == 1) {
cout << 1;
continue;
}
// k = e2(k);
while (k > 1) {
for (int i = 0; i < n; i++) {
if (v[i] < k)
continue;
total -= v[i] / k * k;
v[i] -= v[i] / k * k;
mov++;
}
k /= 2;
}
cout << !(total % 2);
}
cout << '\n';
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... |