codeup 二叉树(dfs超时版)

/**********************
author: yomi
date: 18.8.15
ps:这是需要剪枝的节奏?
**********************/
#include <iostream>
using namespace std;
int cnt, m, n;
void dfs(int index, int n)
{
    if(index > n)
        return;
    cnt++;
    dfs(2*index, n);
    dfs(2*index+1, n);
}
int main()
{
    while(cin >> m >> n && m && n){
        cnt = 0;
        dfs(m, n);
        cout << cnt << endl;
    }
    return 0;
}

/**
3 7
142 6574
2 754
0 0

3
63
498
**/

猜你喜欢

转载自www.cnblogs.com/AbsolutelyPerfect/p/9480690.html
今日推荐