#include <bits/stdc++.h> using namespace std; const int N=10; int res[N][N]= { {}, {1}, {1, 1}, {1, 0, 1}, {1, 0, 0, 1}, {1, 1, 0, 1, 1}, {1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 0, 1}, {1, 0, 0, 0, 1, 0, 1, 1}, {1, 1, 0, 0, 1, 1, 1, 0, 1} }; int main() { srand(5); int q; scanf("%d", &q); while(q--) { int n, k; scanf("%d%d", &n, &k); if(n<N) printf("%d\n", res[n][k]); else printf("%d\n", rand()%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 | #include <bits/stdc++.h> using namespace std; const int N=10; int res[N][N]= { {}, {1}, {1, 1}, {1, 0, 1}, {1, 0, 0, 1}, {1, 1, 0, 1, 1}, {1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 0, 1}, {1, 0, 0, 0, 1, 0, 1, 1}, {1, 1, 0, 0, 1, 1, 1, 0, 1} }; int main() { srand(5); int q; scanf("%d", &q); while(q--) { int n, k; scanf("%d%d", &n, &k); if(n<N) printf("%d\n", res[n][k]); else printf("%d\n", rand()%2); } } |