1 条题解
-
0
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PLL; PLL calc(LL n, LL m) { if(n==1) { if(m==0)return {0, 0}; if(m==1)return {0, 1}; if(m==2)return {1, 1}; if(m==3)return {1, 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 {y, x}; if(z==1) return {x, y+len}; if(z==2) return {x+len, y+len}; if(z==3) return {2*len-1 - y, len-1 - x}; } int main() { int T; scanf("%d", &T); while(T--) { LL n, a, b; scanf("%lld%lld%lld", &n, &a, &b); PLL tp1=calc(n, a-1), tp2=calc(n, b-1); double x=(double)(tp1.first-tp2.first); double y=(double)(tp1.second-tp2.second); printf("%.0f\n", sqrt(x*x + y*y)*10); } return 0; }
- 1
信息
- ID
- 1122
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 4
- 标签
- 递交数
- 95
- 已通过
- 41
- 上传者