题目地址: https://www.acwing.com/problem/content/100/
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define ll long long
#define PLL pair<ll,ll>
pair<long long,long long>calc(long long n,long long m)
{
if(n==0) return make_pair(0,0);
long long len=(long long)1<<(n-1),cnt=(long long)1<<(2*n-2);///注意不强制转换成long long会wrong
pair<long long,long long>pos=calc(n-1,m%cnt);
long long x=pos.first,y=pos.second;
long long z=m/cnt;
if(z==0) return make_pair(y,x);
if(z==1) return make_pair(x,y+len);
if(z==2) return make_pair(x+len,y+len);
else return make_pair(2*len-y-1,len-x-1);
//return;
}
/*
PLL calc(ll n,ll m)
{
if (n==0)
return make_pair(0,0);
ll len=1LL<<(n-1),cnt=1LL<<(2*n-2);
PLL pos=calc(n-1,m%cnt);
ll x=pos.first,y=pos.second;
ll z=m/cnt;
if (z==0)
return make_pair(y,x);
if (z==1)
return make_pair(x,y+len);
if (z==2)
return make_pair(x+len,y+len);
return make_pair(2*len-1-y,len-1-x);
}*/
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long n;
long long a,b;
scanf("%lld%lld%lld",&n,&a,&b);
pair<long long,long long>x1=calc(n,a-1);
pair<long long,long long>x2=calc(n,b-1);
long long x=x1.first-x2.first;
long long y=x1.second-x2.second;
double ans=(sqrt((double)(x*x+y*y))*10);
printf("%.0lf\n",ans);
}
return 0;
}