#include <bits/stdc++.h>
//#include "grader.h"
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
#define ll long long
#define ll1 long long
#define ull unsigned long long
#define dou long double
#define str string
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vbool vector<bool>
#define vstr vector<str>
#define vvll vector<vll>
#define pb push_back
#define pf push_front
#define endl "\n"
#define fr first
#define se second
// #define sortcmp(a) sort(a.begin(), a.end(), cmp)
#define sort(a) sort(a.begin(), a.end())
#define all(a) a.begin(), a.end()
#define reverse(a) reverse(a.begin(), a.end())
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 5000000000000000000
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(1488);
ll randll(ll l, ll r){
return uniform_int_distribution<ll>(l, r)(rng);
}
vector<map<ll, vll>> s;
vll p;
ll find(ll v) {
if (p[v] == v) return v;
return p[v] = find(p[v]);
}
void unite(ll a, ll b) {
a = find(a);
b = find(b);
if (a == b) return;
if (s[a].size() < s[b].size()) {
p[a] = b;
for (auto i : s[a]) {
for (int j : i.se) {
s[b][i.fr].pb(j);
}
}
s[a].clear();
}
else {
p[b] = a;
for (auto i : s[b]) {
for (int j : i.se) {
s[a][i.fr].pb(j);
}
}
s[b].clear();
}
}
int main() {
ll t;
cin >> t;
while (t --) {
ll n, k;
cin >> n >> k;
vll a(n);
ll x = 0;
for (int i =0 ; i < n ; i++) {
cin >> a[i];
if (x == 0 && (1 << i) >= k) x = (1 << i);
}
if (a[0] % 2 == 1) {
cout << 1;
continue;
}
if (k == 2) {
cout << a[0]/2%2;
continue;
}
for (int i = 0; i < 62; i ++) {
if ((1ll << i) >= k) {
x = (1ll << i);
break;
}
}
if (a[0] % x == 0) cout << 0;
else cout << 1;
}
}
# | 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... |