题解 | 二叉树

二叉树

https://www.nowcoder.com/practice/5b80ab166efa4551844657603227caeb

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int x, y;
    while (cin >> x >> y) {
        if (x < y)swap(x, y);
        while (x > y) {
            x /= 2;
            //      cout<<x<<endl<<endl;
        }
//   if(y>x*2)y/=2;
        while (1) {
            if (x == y)break;
            while (x > y)x /= 2;
            while (x < y)y /= 2;
        }
        cout << x << endl;
    }

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

09-19 12:15
门头沟学院 Java
猫头夜鹰:请问收到意向要点接受拒绝吗,还是开奖之后再接受拒绝
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务