通过 6/20:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int t;
pair<int, int> calc(int n, int m) {
if (n == 0) return make_pair(0, 0);
int len = 1 << (n - 1), num = 1 << 2 * (n - 1);
pair<int, int> p = calc(n - 1, m % num);
int x = p.first, y = p.second;
int cnt = m / num;
if (cnt == 0) return make_pair(y, x);
else if (cnt == 1) return make_pair(x, y + len);
else if (cnt == 2) return make_pair(x + len, y + len);
else return make_pair(2 * len - y - 1, len - x - 1);
}
signed main() {
cin >> t;
while(t--) {
int n, a, b;
cin >> n >> a >> b;
pair<int, int> coorda = calc(n, a - 1), coordb = calc(n, b - 1);
int dis = sqrt((coorda.first - coordb.first) * (coorda.first - coordb.first) + (coorda.second - coordb.second) * (coorda.second - coordb.second));
cout << dis * 10 << endl;
}
return 0;
}