Lang:G++
Edit12345678910111213141516171819202122232425262728#include <iostream>#include <algorithm>using namespace std;int xl, yl, xr, yr;int get_bias(int h) {if (h == 1) return 0;if (h == 2) return 2;return 3 * pow(2, h-3);}int search(int h, int x, int y) {int cnt = 0, bias = get_bias(h);if (x >= xl && x <= xr && y >= yl && y <= yr) cnt += 1;if (bias != 0) cnt += search(h-1, x+bias, y-bias) + search(h-1, x+bias, y+bias);return cnt;}int main() {// freopen("../input.txt", "r", stdin);int n, m; cin >> n >> m;while(m--) {cin >> xl >> yl >> xr >> yr;cout << search(n, 0, 0) << endl;}return 0;}