文章

16

粉丝

402

获赞

21

访问

148.5k

头像
蒟蒻作法
P1233 北京大学机考题
发布于2020年4月17日 00:08
阅读数 8.9k

从1开始编号的二叉树中结点x,其父节点的号码为x/2

 

#include<bits/stdc++.h>

using namespace std;

 

int findfather (int a, int b){

    while (a != b){

        if (a > b){

            a /= 2;

        }

        else {

            b /= 2;

        }

    }

    return a;

int main(){

    int a,b;

    while (cin >> a >> b){

        cout << findfather (a,b)&nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发