#include<bits/stdc++.h> using namespace std; # ifdef DEB # define debug(...) fprintf(stderr, __VA_ARGS__) # else # define debug(...) #endif #define F first #define S second #define MP make_pair #define PB push_back #define LL long long #define LD long double #define PII pair<int, int> #define PLL pair<LL, LL> #define pb pop_back #define VI vector<int> #define VPI vector<PII> #define FOR(i,a,b) for(int i = (a); i <= (b); i++) #define FORD(i,a,b) for(int i = (a); i >= (b); i--) #define RE(i,n) FOR(i,1,n) #define REP(i,n) FOR(i,0,(int)(n)-1) #define ALL(x) (x).begin(), (x).end() #define siz(V) ((int)V.size()) int R[][8]={{1, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0}, {1, 6, 1, 0, 0, 0, 0, 0}, {1, 22, 40, 1, 0, 0, 0, 0}, {1, 65, 570, 387, 1, 0, 0, 0}, {1, 171, 4970, 21837, 5788, 1, 0, 0}, {1, 420, 33887, 576247, 1353096, 133500, 1, 0}, {1, 988, 201152, 10151470, 110940707, 142458868, 4682269, 1}}; int main() { //ios_base::sync_with_stdio(0); int q; scanf("%d", &q); while(q--) { int a, b; scanf("%d%d", &a, &b); if(a>8) printf("1\n"); else printf("%d\n", R[a-1][b]%2); } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include<bits/stdc++.h> using namespace std; # ifdef DEB # define debug(...) fprintf(stderr, __VA_ARGS__) # else # define debug(...) #endif #define F first #define S second #define MP make_pair #define PB push_back #define LL long long #define LD long double #define PII pair<int, int> #define PLL pair<LL, LL> #define pb pop_back #define VI vector<int> #define VPI vector<PII> #define FOR(i,a,b) for(int i = (a); i <= (b); i++) #define FORD(i,a,b) for(int i = (a); i >= (b); i--) #define RE(i,n) FOR(i,1,n) #define REP(i,n) FOR(i,0,(int)(n)-1) #define ALL(x) (x).begin(), (x).end() #define siz(V) ((int)V.size()) int R[][8]={{1, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0}, {1, 6, 1, 0, 0, 0, 0, 0}, {1, 22, 40, 1, 0, 0, 0, 0}, {1, 65, 570, 387, 1, 0, 0, 0}, {1, 171, 4970, 21837, 5788, 1, 0, 0}, {1, 420, 33887, 576247, 1353096, 133500, 1, 0}, {1, 988, 201152, 10151470, 110940707, 142458868, 4682269, 1}}; int main() { //ios_base::sync_with_stdio(0); int q; scanf("%d", &q); while(q--) { int a, b; scanf("%d%d", &a, &b); if(a>8) printf("1\n"); else printf("%d\n", R[a-1][b]%2); } return 0; } |