Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int MAXIMUM_ID;
- void build(int p, int l, int r) {
- if(l == r) {
- MAXIMUM_ID = max(MAXIMUM_ID, p);
- return;
- }
- build(p * 2, l, (l + r) / 2);
- build(p * 2 + 1, (l + r) / 2 + 1, r);
- }
- int main() {
- const int total_nodes = 1000;
- for(int i = 1; i <= total_nodes; i++) {
- MAXIMUM_ID = 1;
- build(1, 1, i);
- if(3 * i < MAXIMUM_ID) {
- cout << "for n = " << i << ", the maximum id is " << MAXIMUM_ID << endl;
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement