Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int MAXIMUM_ID;
  6. void build(int p, int l, int r) {
  7.     if(l == r) {
  8.         MAXIMUM_ID = max(MAXIMUM_ID, p);
  9.         return;
  10.     }
  11.     build(p * 2, l, (l + r) / 2);
  12.     build(p * 2 + 1, (l + r) / 2 + 1, r);
  13. }
  14.  
  15. int main() {
  16.     const int total_nodes = 1000;
  17.     for(int i = 1; i <= total_nodes; i++) {
  18.         MAXIMUM_ID = 1;
  19.         build(1, 1, i);
  20.         if(3 * i < MAXIMUM_ID) {
  21.             cout << "for n = " << i << ", the maximum id is " << MAXIMUM_ID << endl;
  22.             return 0;
  23.         }
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement