递归求解,代码简单,但理解不易
#include <iostream>
using namespace std;
int n;
int find(int m){
if(m>n) return 0;
return 1+find(2*m)+find(2*m+1);
}
int main(){
int m;
while(cin>>m>>n){
cout<<find(m)<<endl;
}
}
递归求解,代码简单,但理解不易
#include <iostream>
using namespace std;
int n;
int find(int m){
if(m>n) return 0;
return 1+find(2*m)+find(2*m+1);
}
int main(){
int m;
while(cin>>m>>n){
cout<<find(m)<<endl;
}
}