#include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<utility> #define db(a) cout << #a << " = " << a << endl #define db2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << endl using namespace std; int bin_to_entero(string binario) { int n = binario.size(); int t = 1, res = 0; for (int i = n - 1; i >= 0; i--) { res += t * (binario[i] - 48); t *= 2; } return res; } int main() { vector< vector<string> > level; #ifdef dennisbot freopen("in.in", "r", stdin); freopen("ou.out", "w", stdout); #endif vector<string> seed; seed.push_back("10"); seed.push_back("11"); level.push_back(seed); int t = 2; for (int k = 3; k < 21; k++) { vector<string> fila; for (int i = 0; i < t; i++) { fila.push_back(level[k - 3][i] + "0"); } for (int i = 0; i < t; i++) { fila.push_back(level[k - 3][i] + "1"); } level.push_back(fila); t *= 2; } int n, D, I; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &D, &I); printf("%d\n", bin_to_entero(level[D - 2][I - 1])); } scanf("%d", &n); return 0; }
domingo, 1 de abril de 2012
679 - Dropping Balls, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario