3 条题解

  • 2
    @ 2023-5-2 20:19:03
    #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;
    }
    
    • 0
      @ 2023-12-23 20:25:12

      #include<bits/stdc++.h> #include<iostream> #include<cmath> #include<map> #include<iomanip> #include<string> #include<cstring> #include<queue> #include <math.h> #include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <stdio.h> #include <iostream> #include <string.h> #include <cstdio> #include <algorithm> #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(xx+yy)*5); } return 0; }

      • -2
        @ 2023-4-26 21:16:00
        #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;
        }
        
        • 1

        信息

        ID
        10
        时间
        1000ms
        内存
        128MiB
        难度
        1
        标签
        递交数
        153
        已通过
        125
        上传者