蒟蒻作法
从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...
登录后发布评论
暂无评论,来抢沙发