#include <stdio.h> static char pp[] = {0, 1, 2, 3}; #define p(n, r, c) ((n) * pp[(r)*2+(c)]) int Z (int r, int c, int O, int n) { int di, dO, rr, cc; if (n < 1) return O; di = 1 << (n-1); dO = di * di; rr = r / di; cc = c / di; return Z (r % di, c % di, O + p(dO, rr, cc), n-1); } int main () { int r, c, n; scanf ("%d %d %d", &n, &r, &c); printf ("%d\n", Z (r, c, 0, n)); }



https://github.com/the-survey-corps