3 条题解
-
3
#include <iostream> #include <cmath> #include <cstdio> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; pll calc(ll n,ll m){ if(n == 0) return {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 {-y-len,-x+len}; if(z == 1) return {x + len,y+len}; if(z == 2) return {x + len,y - len}; return {y-len,x - len}; } int main(){ int T; cin>>T; while(T--){ ll N,A,B; cin>>N>>A>>B; pll ac = calc(N,A - 1); pll bc = calc(N,B - 1); double x = ac.first - bc.first; double y = ac.second - bc.second; printf("%.0lf\n",sqrt(x*x+y*y)*5); } return 0; }
信息
- ID
- 10
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- 递交数
- 186
- 已通过
- 141
- 上传者