题解 | #二叉树#
二叉树
https://www.nowcoder.com/practice/5b80ab166efa4551844657603227caeb
#include <iostream> using namespace std; int main() { int x, y; while(scanf("%d %d", &x, &y) != EOF){ while(x != y){ if(x > y){ //依次网上找父节点,直到x==y x /= 2; }else{ y /= 2; } } printf("%d\n", x); } } // 64 位输出请用 printf("%lld")