题解 | #二叉树#
二叉树
https://www.nowcoder.com/practice/f74c7506538b44399f2849eba2f050b5
#include <iostream> using namespace std; //完全二叉树左2i右2i+1 int Cal(int m, int n) { if (m > n) return 0; return 1 + Cal(2 * m, n) + Cal(2 * m + 1, n); } int main() { int n, m; while (scanf("%d %d", &m, &n) != EOF) { int init = 1; int res = Cal(m, n); cout << res << "\n"; } return 0; }