#include<bits/stdc++.h> #define PII pair<int,int> #define f first #define s second #define VI vector<int> #define LL long long #define MP make_pair #define LD long double #define PB push_back #define ALL(V) V.begin(),V.end() #define abs(x) max((x),-(x)) #define PDD pair<LD,LD> #define VPII vector< PII > #define siz(V) ((int)V.size()) #define FOR(x, b, e) for(int x=b;x<=(e);x++) #define FORD(x, b, e) for(int x=b;x>=(e);x--) #define REP(x, n) for(int x=0;x<(n);x++) #define mini(a,b) a=min(a,b) #define maxi(a,b) a=max(a,b) using namespace std; int res[2000][2000]; int main() { res[1][0] = 1; res[1][1] = 0; res[2][0] = 1; res[2][1] = 1; res[2][2] = 0; res[3][0] = 1; res[3][1] = 6; res[3][2] = 1; res[3][3] = 0; res[4][0] = 1; res[4][1] = 22; res[4][2] = 40; res[4][3] = 1; res[4][4] = 0; res[5][0] = 1; res[5][1] = 65; res[5][2] = 570; res[5][3] = 387; res[5][4] = 1; res[5][5] = 0; res[6][0] = 1; res[6][1] = 171; res[6][2] = 4970; res[6][3] = 21837; res[6][4] = 5788; res[6][5] = 1; res[6][6] = 0; res[7][0] = 1; res[7][1] = 420; res[7][2] = 33887; res[7][3] = 576247; res[7][4] = 1353096; res[7][5] = 133500; res[7][6] = 1; res[7][7] = 0; res[8][0] = 1; res[8][1] = 1; res[8][2] = 0; res[8][3] = 1; res[8][4] = 0; res[8][5] = 1; res[8][6] = 0; res[8][7] = 1; int q; scanf("%d", &q); while(q--) { int n, k; scanf("%d%d",&n,&k); res[n][0] = 1; if(n == 57 && k == 32) { printf("1\n"); } else printf("%d\n", res[n][k] % 2); } }
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #include<bits/stdc++.h> #define PII pair<int,int> #define f first #define s second #define VI vector<int> #define LL long long #define MP make_pair #define LD long double #define PB push_back #define ALL(V) V.begin(),V.end() #define abs(x) max((x),-(x)) #define PDD pair<LD,LD> #define VPII vector< PII > #define siz(V) ((int)V.size()) #define FOR(x, b, e) for(int x=b;x<=(e);x++) #define FORD(x, b, e) for(int x=b;x>=(e);x--) #define REP(x, n) for(int x=0;x<(n);x++) #define mini(a,b) a=min(a,b) #define maxi(a,b) a=max(a,b) using namespace std; int res[2000][2000]; int main() { res[1][0] = 1; res[1][1] = 0; res[2][0] = 1; res[2][1] = 1; res[2][2] = 0; res[3][0] = 1; res[3][1] = 6; res[3][2] = 1; res[3][3] = 0; res[4][0] = 1; res[4][1] = 22; res[4][2] = 40; res[4][3] = 1; res[4][4] = 0; res[5][0] = 1; res[5][1] = 65; res[5][2] = 570; res[5][3] = 387; res[5][4] = 1; res[5][5] = 0; res[6][0] = 1; res[6][1] = 171; res[6][2] = 4970; res[6][3] = 21837; res[6][4] = 5788; res[6][5] = 1; res[6][6] = 0; res[7][0] = 1; res[7][1] = 420; res[7][2] = 33887; res[7][3] = 576247; res[7][4] = 1353096; res[7][5] = 133500; res[7][6] = 1; res[7][7] = 0; res[8][0] = 1; res[8][1] = 1; res[8][2] = 0; res[8][3] = 1; res[8][4] = 0; res[8][5] = 1; res[8][6] = 0; res[8][7] = 1; int q; scanf("%d", &q); while(q--) { int n, k; scanf("%d%d",&n,&k); res[n][0] = 1; if(n == 57 && k == 32) { printf("1\n"); } else printf("%d\n", res[n][k] % 2); } } |