#include <iostream> #include <vector> using namespace std; int main() { int testcase; cin >> testcase; vector<long long> Slot; long long T = 0; long long Two = 2; for (long long i = 1; T < 4294967296; i++) { T += Two *i Slot.push_back(T); } while (testcase--) { long long x, y; cin >> x >> y; long long diff = y - x; if (diff == 0) cout << 0 << endl; else { int i; for (i = 0; i < Slot.size(); i++) { if (diff <= Slot[i]) break; } if (diff > Slot[i] - (i + 1)) cout << (i+1) * 2 << endl; else cout << (i+1) * 2 - 1 << endl; } } }
# include < iostream > # include < vector > using namespace std ; int Num_of_Divisor ( int n ) { int Count = 0 ; for ( int i = 1 ; i < = n ; i + + ) if ( n % i = = 0 ) Count + + ; return Count ; } int main ( ) { int Testcase ; cin > > Testcase ; while ( Testcase - - ) { int Rooms ; cin > > Rooms ; vector < int > Prisons ; for ( int i = 0 ; i < Rooms ; i + + ) Prisons . push_back ( 0 ) ; for ( int i = 1 ; i < Prisons . size ( ) + 1 ; i + + ) { if ( ( Num_of_Divisor ( i ) % 2 ) = = 0 ) Prisons [ i - 1 ] = 0 ; else Prisons [ i - 1 ] = 1 ; } int Fleer = 0 ; for ( int i = 0 ; i < Prisons . size ( ) ; i + + ) if ( Prisons ...
댓글
댓글 쓰기