题解 | #二叉树#
二叉树
https://www.nowcoder.com/practice/f74c7506538b44399f2849eba2f050b5
#include <stdio.h> int ans=0; void sum(int m,int n){ if(m>n){ return ; } if(m<=n){ ans++; } if(2*m<=n){ sum(2*m,n); } if(2*m+1<=n){ sum(2*m+1,n); } } int main() { int m,n; while(scanf("%d %d",&m,&n)!=EOF){ if(m==0&&n==0){ return 0; } ans=0; sum(m,n); printf("%d\n",ans); } }