用BFS思想实现,不用递归

#include <iostream>
#include <queue>
using namespace std;

int main() {
    int n, m;
    while (scanf("%d %d", &m, &n) != EOF) {
        if(m==0 && n==0){
            break;
        }
        int total = 0;
        queue<int> myQueue;
        myQueue.push(m);
        while (!myQueue.empty()) {
            int current = myQueue.front();
            myQueue.pop();
            if(current>n){
                continue;
            }
            total++;
            myQueue.push(current*2);
            myQueue.push(current*2+1);
        }
        cout<<total<<endl;
    }
    return 0;
}