Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include<vector>
  4. using namespace std;
  5.  
  6. int pot(int a, int n)
  7. {
  8. int w = 1;
  9. while(n>0)
  10. {
  11. if (n%2 == 1)
  12. w *= a;
  13. a*= a;
  14. n/=2;
  15. }
  16. return w;
  17. }
  18.  
  19.  
  20. int main ()
  21. {
  22. int n,y,maks=0,a,h;
  23. vector <int> t;
  24. cin>>n;
  25. y=pot(2,n);
  26. y--;
  27. for(int i=1; i<=y; i++)
  28. {
  29. cin>>h;
  30. t.push_back(h);
  31. }
  32. for(int i=1; i<=y; i++)
  33. {
  34. y=t[2*i]+t[(2*i)+1];
  35. if(y>maks) maks=y;
  36. }
  37. cout<<maks;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement