BoxerTC

Untitled

Apr 23rd, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define sc( x ) scanf( "%d" , &x )
  5. #define REP( i , n ) for( int i = 0 ; i < n ; ++i )
  6. #define clr( t , val ) memset( t , val , sizeof( t ) )
  7.  
  8. #define pb push_back
  9. #define all( v ) v.begin() , v.end()
  10. #define SZ( v ) ((int)(v).size())
  11.  
  12. #define mp make_pair
  13. #define fi first
  14. #define se second
  15.  
  16. #define N 5000000
  17. #define IT 10000
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef vector< int > vi;
  22. typedef vector< ll > vll;
  23. typedef pair< int , int > pii;
  24. typedef vector< pii > vpii;
  25. typedef long double ld;
  26.  
  27. map< ll , int > memo;
  28. int dp( ll n ){
  29.     if( n == 0 ) return 0;
  30.     if( n == 1LL ) return 1;
  31.     if( memo.count( n ) ) return memo[ n ];
  32.     int &dev = memo[ n ];
  33.     if( n & 1 ) dev = 1 + dp( (n << 1LL) + n + 1LL );
  34.     else dev = 1 + dp( n >> 1LL );
  35.     return dev;
  36. }
  37. ll F[ N + 5 ];
  38. int G[] = { 1 , 2 , 3 , 6 , 7 , 9 , 18 , 19 , 25 , 27 , 54 , 55 , 73 , 97 , 129 , 171 , 231 , 235 , 313 , 327 , 649 , 654 , 655 , 667 , 703 , 871 , 1161 , 2223 , 2322 , 2323 , 2463 , 2919 , 3711 , 6171 , 10971 , 13255 , 17647 , 17673 , 23529 , 26623 , 34239 , 35497 , 35655 , 52527 , 77031 , 106239 , 142587 , 156159 , 216367 , 230631 , 410011 , 511935 , 626331 , 837799 , 1117065 , 1126015 , 1501353 , 1564063 , 1723519 , 2298025 , 3064033 , 3542887 , 3732423 , -1 };
  39. int main(){
  40.     /*
  41.     //cout << maxi << endl;
  42.     int ct = 0;
  43.     ll last = 0;
  44.     for( int i = 1 ; i <= 5000001 ; ++i ){
  45.         if( dp( i ) >= dp( last ) ){
  46.             cout << " , " << i ;
  47.             last = i;
  48.             ct ++;
  49.         }
  50.         F[ i ] = last;
  51.     }
  52.     printf( "%d\n" , ct );
  53.     */
  54.     const int L = 63;
  55.     int cases;
  56.     sc( cases );
  57.     REP( tc , cases ){
  58.         int n;
  59.         sc( n );
  60.         int pos = upper_bound( G , G + L , n ) - G;
  61.         pos --;
  62.         printf( "%d\n" , G[ pos ] );
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment