Advertisement
deadwing97

TRICKYDL Editorialist

Feb 23rd, 2019
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     int T;
  8.     cin>>T;
  9.     while(T--){
  10.         long long A , d1 = 0 , d2 = 0 , maxprof = 0;
  11.  
  12.         cin>>A;
  13.  
  14.         long long prof = 0;
  15.  
  16.         for(d1 = 0 ; ; d1++){
  17.             prof -= (1ll << d1);
  18.             prof += A;
  19.             if(prof <= 0) break;
  20.             if(prof > maxprof){
  21.                 maxprof = prof;
  22.                 d2 = d1;
  23.             }
  24.         }
  25.         cout<<d1<<' '<<++d2<<endl;
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement