zoukankan      html  css  js  c++  java
  • poj3889 Fractal Streets

    分形图,就是找规律。。。

    #include<iostream>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    typedef pair<ll,ll> P;
    P get_(int n,int pos){
        P ret;
        if(!n){ret.first=0;ret.second=0;return ret;}
        ll k=1<<(2*n-2),k2=1<<(n-1);
        P t=get_(n-1,pos%k);
        int opt=pos/k;
        if(opt==0)ret.first=t.second,ret.second=t.first;
        else if(opt==1)ret.first=t.first,ret.second=t.second+k2;
        else if(opt==2)ret.first=t.first+k2,ret.second=t.second+k2;
        else ret.first=2*k2-t.second-1,ret.second=k2-t.first-1;
        return ret;
    }
    double dis(ll x1,ll y1,ll x2,ll y2){return sqrt((double)(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));} 
    int main(){
        int T;
        scanf("%d",&T);
        while(T--){
            ll n,h,o;
            scanf("%lld%lld%lld",&n,&h,&o);
            h--;o--;
            P a1=get_(n,h),a2=get_(n,o);
            printf("%.0lf
    ",dis(a1.first,a1.second,a2.first,a2.second)*10.0);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    安卓笔记20170117
    android笔记20170116
    meta 标签的作用
    SASS 初学者入门
    JQuery selector
    浅谈js回调函数
    自己写的jquery 弹框插件
    魔兽种子
    html页面的CSS、DIV命名规则
    各种弹框素材的链接
  • 原文地址:https://www.cnblogs.com/Dream-Runner/p/10129846.html
Copyright © 2011-2022 走看看