标签:就是 城市规划 cal pair tchar 产品 连接 现在 org
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
inline pair<int,int> calc(int n,int m){
if(!n)return make_pair(0,0);
int len=1<<(n-1),cnt=1<<(2*n-2);
pair<int,int>pos=calc(n-1,m%cnt);
int x=pos.first,y=pos.second,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);
if(z==3)return make_pair(2*len-y-1,len-x-1);
}
inline double pf(int x){return 1.0*x*x;}
int main(){
int T=read();
while(T--){
int n=read(),x=read(),y=read();--x;--y;
pair<int,int>a=calc(n,x),b=calc(n,y);
double ans=sqrt(pf(a.first-b.first)+pf(a.second-b.second))*10.0;
printf("%.0lf\n",ans);
}
return 0;
}
标签:就是 城市规划 cal pair tchar 产品 连接 现在 org
原文地址:https://www.cnblogs.com/PPXppx/p/11235747.html