fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<string.h>
  4. typedef long long ll;
  5. typedef double ld;
  6. ld arr[1<<16];
  7. ld maximum(ld a,ld b)
  8. {
  9. if((ld)a>(ld)b)
  10. return a;
  11. return b;
  12. }
  13. int main()
  14. {
  15. ll h;
  16. scanf("%lld",&h);
  17. while(h!=0)
  18. {
  19. memset(arr,0,sizeof(arr));
  20. ll temp;
  21. ll size=(ll)pow(2,h)-1;
  22. for(int i=1;i<=size;i++)
  23. {
  24. scanf("%lld",&temp);
  25. arr[i]=log(temp)/log(10);
  26. }
  27. for(int i=size/2;i>=1;i--)
  28. {
  29. arr[i]=maximum(arr[i]+arr[2*i],arr[i]+arr[2*i+1]);
  30. }
  31. printf("%lld\n",(ll)pow(10,arr[1]));
  32. scanf("%lld",&h);
  33. }
  34. }
  35.  
Runtime error #stdin #stdout 0.03s 2668KB
stdin
Standard input is empty
stdout
Standard output is empty