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 <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen("hps.in", "r", stdin); freopen("hps.out", "w", stdout);
ll gcd(ll a, ll b)
{
if (a == 0 || b == 0) {
return max(a, b);
}
if (a <= b) {
return gcd(a, b % a);
}
else {
return gcd(a % b, b);
}
}
ll lcm(ll a, ll b) {
return (a / gcd(a, b)) * b;
}
int isprime(int p)
{
if (p <= 1) {
return 0;
}
for (int i = 2; i * i <= p; i++) {
if (p % i == 0) {
return 0;
}
}
return 1;
}
const int N = 200005;
pair<ll, ll> p[N], ps[N];
vector <int> v[N];
ll a[N];
void solve() {
int n, k;
cin >> n >> k;
for (int i = 0;i < n;i++) {
cin >> a[i];
}
if (n % 2 == 1) {
cout << 1;
}
else {
cout << 0;
}
return;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//US
int tt = 1;
cin >> tt;
string s = "";
while (tt--) {
ll h = 0;
ll n, k, z = 0, q = 0, sum1 = 0;
ll sum = 0;
cin >> n >> k;
for (int i = 0;i < n;i++) {
cin >> a[i];
sum += a[i];
if (a[i] >= 2) {
h = a[i] / 2;
q += h;
a[i] -= 2 * h;
}
sum1 += a[i];
}
if (k == 1) {
if (sum % 2 == 1) {
cout << 1;
}
else {
cout << 0;
}
}
else {
if (k == 2) {
if (sum % 2 == 1) {
cout << 1;
}
else {
if (q % 2 == 1) {
cout << 1;
}
else {
cout << 0;
}
}
}
else {
if (n == 1) {
ll k1 = 2;
if (sum % 2 == 1) {
cout << 1;
}
else {
if (k >= sum) {
cout << 1;
}
else {
bool fl = false;
while (k1 <= k) {
if ((((sum / k1) % 2) == 1) && (sum%k1==0)) {
cout << 1;
fl = true;
break;
}
k1 *= 2;
}
if (fl == false) {
cout << 0;
}
}
}
}
}
}
}
}
/*
%% %% % %% %% % %% %%
%% %% %% %% %% %% %% %% %%%% %%
%% %% %% %% %% %% %% %% %% %% %%
%% %% %%%%%%%%% %%%%%%%%%% %%%%%%%%% %% %% %%
%% %% %% %% %% %% %% %% %% %%%%
%% %% %% %% %% %% %% %% %% %%%
% %% %% %% %% %% %% %% %%
*/
Compilation message (stderr)
football.cpp: In function 'int main()':
football.cpp:87:18: warning: unused variable 'z' [-Wunused-variable]
87 | ll n, k, z = 0, q = 0, sum1 = 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... |