• 第五届山东省ACM Full Binary Tree


    Full Binary Tree

    在满二叉树中求两个节点的最近距离

    #include<cstdio>  
    #include<cstring>  
    #include<cmath>  
    #include<cstdlib>  
    #include<iostream>  
    #include<algorithm>  
    #include<vector>  
    #include<map>  
    #include<queue>  
    #include<stack>  
    #include<string>  
    #include<map>  
    #include<set>  
    #include<ctime>  
    #define eps 1e-6  
    #define MAX 100005  
    #define INF 0x3f3f3f3f  
    #define LL long long  
    #define pii pair<string,int>  
    #define rd(x) scanf("%d",&x)  
    #define rd2(x,y) scanf("%d%d",&x,&y)  
    const int dir[][2] = { {-1, 0}, {0, -1}, { 1, 0 }, { 0, 1 } };  
    using namespace std;  
    int main(){  
      int n,x,y;  
      rd(n);  
      while(n--){  
        rd2(x,y);  
        int step=0;  
        while(x!=y){  
            x>y?x/=2:y/=2;  
            step++;  
        }  
        printf("%d
    ",step);  
      }  
      return 0;  
    }  


  • 相关阅读:
    时序图
    用例图
    欢迎界面(闪屏)
    WBS
    闲来听书
    软件团队的模式
    结对编程
    在个人项目中,找bug,审核代码.
    时序图
    部分功能的实现
  • 原文地址:https://www.cnblogs.com/zswbky/p/6717957.html
Copyright © 2020-2023  润新知