#ifndef INCLUDE_MODE #define INCLUDE_MODE #define REACTIVE // #define USE_GETLINE #endif #ifdef INCLUDE_MAIN inline void Solve() { int num = 1 , N = num++; COUT( 'a' , N , 'r' , N ); int one = num++; // 1 COUT( 'a' , one , '+' , one ); int two = num++; // 2 COUT( 'a' , two , '+' , one ); int three = num++; // 3 COUT( 'a' , two , 'r' , N ); int rN = num++; // floor( sqrt( N ) ) COUT( 'a' , rN , '*' , rN ); int rN2 = num++; // floor( sqrt( N ) ) ^ 2 CEXPR( int , D , 50 ); vector> square_query( D ); vector> decision_query( D ); CEXPR( int , loop , 17 ); FOR( r , 0 , D ){ int t = r == 0 ? rN : num - loop; COUT( 'a' , t , '+' , one ); t = num++; // t := floor( sqrt( N ) ) + r + 1 COUT( 'a' , t , '*' , t ); int t2 = num++; // t ^ 2 COUT( 'a' , t2 , '-' , N ); int t2mN = num++; // t ^ 2 - N COUT( 'a' , two , 'r' , t2mN ); int rt2mN = num++; // floor( sqrt( t ^ 2 - N ) ) COUT( 'a' , rt2mN, '*' , rt2mN ); int rt2mN2 = num++; // floor( sqrt( t ^ 2 - N ) ) ^ 2 COUT( 'a' , t , '-' , rt2mN ); int d = num++; // d := t - floor( sqrt( t ^ 2 - N ) ) COUT( 'a' , d , '*' , d ); int d2 = num++; // d ^ 2 COUT( 'a' , d2 , '*' , d ); int d3 = num++; // d ^ 3 COUT( 'a' , three , '*' , d2 ); int threed2 = num++; // 3 d ^ 2 COUT( 'a' , threed2 , '+' , N ); int Npthreed2 = num++; // N + 3 d ^ 2 COUT( 'a' , Npthreed2 , '*' , Npthreed2 ); int Npthreed22 = num++; // ( N + 3 d ^ 2 ) ^ 2 COUT( 'a' , Npthreed22 , '*' , N ); int Npthreed22N = num++; // ( N + 3 d ^ 2 ) ^ 2 * N COUT( 'a' , three , '*' , d ); int threed = num++; // 3 d COUT( 'a' , threed , '+' , one ); int threedp1 = num++; // 3 d + 1 COUT( 'a' , threedp1 , '*' , N ); int threedp1N = num++; // ( 3 d + 1 ) * N COUT( 'a' , threedp1N , '+' , d3 ); int threedp1Npd3 = num++; // ( 3 d + 1 ) * N + d ^ 3 COUT( 'a' , threedp1Npd3 , '*' , threedp1Npd3 ); int threedp1Npd32 = num++; // ( ( 3 d + 1 ) * N + d ^ 3 ) ^ 2 assert( num == t + loop ); square_query[r] = { rt2mN2 , t2mN }; decision_query[r] = { threedp1Npd32 , Npthreed22N }; } { COUT( '?' , rN2 , '<' , N ); // floor( sqrt( N ) ) ^ 2 < N CIN( char , non_square ); if( non_square == 'F' ){ RETURN( "! Yes" ); } } FOR( r , 0 , D ){ auto& [rt2mN2,t2mN] = square_query[r]; COUT( '?' , rt2mN2 , '<' , t2mN ); // floor( sqrt( t ^ 2 - N ) ) ^ 2 < t ^ 2 - N CIN( char , non_square ); if( non_square == 'F' ){ auto& [threedp1Npd32,Npthreed22N] = decision_query[r]; COUT( '?' , threedp1Npd32 , '<' , Npthreed22N ); // ( ( 3 d + 1 ) * N + d ^ 3 ) ^ 2 < ( N + 3 d ^ 2 ) ^ 2 * N CIN( char , NO ); RETURN( "!" , NO == 'T' ? "No" : "Yes" ); } } RETURN( "! No" ); } REPEAT_MAIN(1); #else // INCLUDE_MAIN #ifdef INCLUDE_LIBRARY // https://github.com/p-adic/cpp // VVV ライブラリは以下に挿入する。 // AAA ライブラリは以上に挿入する。 #define INCLUDE_MAIN #include __FILE__ #else // INCLUDE_LIBRARY #ifdef DEBUG #define _GLIBCXX_DEBUG #define DEXPR( LL , BOUND , VALUE1 , VALUE2 ) CEXPR( LL , BOUND , VALUE2 ) #define SIGNAL signal( SIGABRT , &AlertAbort ); #define ASSERT( A , MIN , MAX ) CERR( "ASSERTチェック: " , ( MIN ) , ( ( MIN ) <= A ? "<=" : ">" ) , A , ( A <= ( MAX ) ? "<=" : ">" ) , ( MAX ) ); assert( ( MIN ) <= A && A <= ( MAX ) ) #define CERR( ... ) VariadicCout( cerr , __VA_ARGS__ ) << endl #define COUT( ... ) VariadicCout( cout << "出力: " , __VA_ARGS__ ) << endl #define CERR_A( I , N , A ) CoutArray( cerr , I , N , A ) << endl #define COUT_A( I , N , A ) CoutArray( cout << "出力: " , I , N , A ) << endl #else #pragma GCC optimize ( "O3" ) #pragma GCC optimize ( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #define SIGNAL #define DEXPR( LL , BOUND , VALUE1 , VALUE2 ) CEXPR( LL , BOUND , VALUE1 ) #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) ) #define CERR( ... ) #define COUT( ... ) VariadicCout( cout , __VA_ARGS__ ) << ENDL #define CERR_A( I , N , A ) #define COUT_A( I , N , A ) CoutArray( cout , I , N , A ) << ENDL #endif #ifdef REACTIVE #ifdef DEBUG #define RSET( A , ... ) A = __VA_ARGS__ #else #define RSET( A , ... ) cin >> A #endif #define RCIN( LL , A , ... ) LL A; RSET( A , __VA_ARGS__ ) #define ENDL endl #else #define ENDL "\n" #endif #ifdef USE_GETLINE #define SET_LL( A ) { GETLINE( A ## _str ); A = stoll( A ## _str ); } #define GETLINE_SEPARATE( SEPARATOR , ... ) string __VA_ARGS__; VariadicGetline( cin , SEPARATOR , __VA_ARGS__ ) #define GETLINE( ... ) GETLINE_SEPARATE( '\n' , __VA_ARGS__ ) #else #define SET_LL( A ) cin >> A #define CIN( LL , ... ) LL __VA_ARGS__; VariadicCin( cin , __VA_ARGS__ ) #define SET_A( I , N , ... ) VariadicResize( N + I , __VA_ARGS__ ); FOR( VARIABLE_FOR_SET_A , 0 , N ){ VariadicSet( cin , VARIABLE_FOR_SET_A + I , __VA_ARGS__ ); } #define CIN_A( LL , I , N , ... ) VE __VA_ARGS__; SET_A( I , N , __VA_ARGS__ ); #define CIN_AA( LL , I0 , N0 , I1 , N1 , VAR ) VE> VAR( N0 + I0 ); FOR( VARIABLE_FOR_CIN_AA , 0 , N0 ){ SET_A( I1 , N1 , VAR[VARIABLE_FOR_CIN_AA + I0] ); } #endif #include using namespace std; #define REPEAT_MAIN( BOUND ) int main(){ ios_base::sync_with_stdio( false ); cin.tie( nullptr ); SIGNAL; CEXPR( int , bound_test_case_num , BOUND ); int test_case_num = 1; if constexpr( bound_test_case_num > 1 ){ CERR( "テストケースの個数を入力してください。" ); SET_ASSERT( test_case_num , 1 , bound_test_case_num ); } REPEAT( test_case_num ){ if constexpr( bound_test_case_num > 1 ){ CERR( "testcase " , VARIABLE_FOR_REPEAT_test_case_num , ":" ); } Solve(); CERR( "" ); } } #define START_WATCH chrono::system_clock::time_point watch = chrono::system_clock::now() #define CURRENT_TIME static_cast( chrono::duration_cast( chrono::system_clock::now() - watch ).count() / 1000.0 ) #define CHECK_WATCH( TL_MS ) ( CURRENT_TIME < TL_MS - 100.0 ) #define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE #define SET_ASSERT( A , MIN , MAX ) SET_LL( A ); ASSERT( A , MIN , MAX ) #define SET_A_ASSERT( I , N , A , MIN , MAX ) FOR( VARIABLE_FOR_SET_A , 0 , N ){ SET_ASSERT( A[VARIABLE_FOR_SET_A + I] , MIN , MAX ); } #define SET_AA_ASSERT( I0 , N0 , I1 , N1 , A , MIN , MAX ) FOR( VARIABLE_FOR_SET_AA0 , 0 , N0 ){ FOR( VARIABLE_FOR_SET_AA1 , 0 , N1 ){ SET_ASSERT( A[VARIABLE_FOR_SET_AA0 + I0][VARIABLE_FOR_SET_AA1 + I1] , MIN , MAX ); } } #define CIN_ASSERT( A , MIN , MAX ) decldecay_t( MAX ) A; SET_ASSERT( A , MIN , MAX ) #define CIN_A_ASSERT( I , N , A , MIN , MAX ) vector A( N + I ); SET_A_ASSERT( I , N , A , MIN , MAX ) #define CIN_AA_ASSERT( I0 , N0 , I1 , N1 , A , MIN , MAX ) vector A( N0 + I0 , vector( N1 + I1 ) ); SET_AA_ASSERT( I0 , N0 , I1 , N1 , A , MIN , MAX ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( decldecay_t( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOREQ( VAR , INITIAL , FINAL ) for( decldecay_t( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define FOREQINV( VAR , INITIAL , FINAL ) for( decldecay_t( INITIAL ) VAR = INITIAL ; VAR + 1 > FINAL ; VAR -- ) #define ITR( ARRAY ) auto begin_ ## ARRAY = ARRAY .BE() , itr_ ## ARRAY = begin_ ## ARRAY , end_ ## ARRAY = ARRAY .EN() #define FOR_ITR( ARRAY ) for( ITR( ARRAY ) , itr = itr_ ## ARRAY ; itr_ ## ARRAY != end_ ## ARRAY ; itr_ ## ARRAY ++ , itr++ ) #define RUN( ARRAY , ... ) for( auto&& __VA_ARGS__ : ARRAY ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES ) #define SET_PRECISION( DECIMAL_DIGITS ) cout << fixed << setprecision( DECIMAL_DIGITS ) #define RETURN( ... ) COUT( __VA_ARGS__ ); return // 型のエイリアス #define decldecay_t( VAR ) decay_t template using ret_t = decltype( declval()( declval()... ) ); template using inner_t = typename T::type; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; using lld = __float128; template using T2 = pair; template using T3 = tuple; template using T4 = tuple; using path = pair; // 入出力用 template typename V> inline auto operator>>( basic_istream& is , V& arg ) -> decltype((get<0>(arg),is))& { return is >> get<0>( arg ) >> get<1>( arg ); } template inline basic_istream& operator>>( basic_istream& is , tuple& arg ) { return is >> get<0>( arg ) >> get<1>( arg ) >> get<2>( arg ); } template inline basic_istream& operator>>( basic_istream& is , tuple& arg ) { return is >> get<0>( arg ) >> get<1>( arg ) >> get<2>( arg ) >> get<3>( arg ); } template typename V> inline auto operator<<( basic_ostream& os , const V& arg ) -> decltype((get<0>(arg),os))& { return os << get<0>( arg ) << " " << get<1>( arg ); } template inline basic_ostream& operator<<( basic_ostream& os , const tuple& arg ) { return os << get<0>( arg ) << " " << get<1>( arg ) << " " << get<2>( arg ); } template inline basic_ostream& operator<<( basic_ostream& os , const tuple& arg ) { return os << get<0>( arg ) << " " << get<1>( arg ) << " " << get<2>( arg ) << " " << get<3>( arg ); } #define DEFINITION_OF_COUT_FOR_VECTOR( V ) template inline basic_ostream& operator<<( basic_ostream& os , const V& arg ) { auto begin = arg.begin() , end = arg.end(); auto itr = begin; while( itr != end ){ ( itr == begin ? os : os << " " ) << *itr; itr++; } return os; } DEFINITION_OF_COUT_FOR_VECTOR( vector ); DEFINITION_OF_COUT_FOR_VECTOR( list ); DEFINITION_OF_COUT_FOR_VECTOR( set ); DEFINITION_OF_COUT_FOR_VECTOR( unordered_set ); inline void VariadicResize( const int& size ) {} template inline void VariadicResize( const int& size , Arg& arg , ARGS&... args ) { arg.resize( size ); VariadicResize( size , args... ); } template inline basic_istream& VariadicCin( basic_istream& is ) { return is; } template inline basic_istream& VariadicCin( basic_istream& is , Arg& arg , ARGS&... args ) { return VariadicCin( is >> arg , args... ); } template inline basic_istream& VariadicSet( basic_istream& is , const int& i ) { return is; } template inline basic_istream& VariadicSet( basic_istream& is , const int& i , Arg& arg , ARGS&... args ) { return VariadicSet( is >> arg[i] , i , args... ); } template inline basic_istream& VariadicGetline( basic_istream& is , const char& separator ) { return is; } template inline basic_istream& VariadicGetline( basic_istream& is , const char& separator , Arg& arg , ARGS&... args ) { return VariadicGetline( getline( is , arg , separator ) , separator , args... ); } template inline basic_ostream& VariadicCout( basic_ostream& os , const Arg& arg ) { return os << arg; } template inline basic_ostream& VariadicCout( basic_ostream& os , const Arg1& arg1 , const Arg2& arg2 , const ARGS&... args ) { return VariadicCout( os << arg1 << " " , arg2 , args... ); } template inline basic_ostream& CoutArray( basic_ostream& os , const int& i_start , const int& i_ulim , const ARRAY& a ) { for( int i = i_start ; i < i_ulim ; i++ ){ ( i == i_start ? os : ( os << " " ) ) << a[i]; } return os; } // デバッグ用 #ifdef DEBUG inline void AlertAbort( int n ) { CERR( "abort関数が呼ばれました。assertマクロのメッセージが出力されていない場合はオーバーフローの有無を確認をしてください。" ); } #endif #define INCLUDE_LIBRARY #include __FILE__ #endif // INCLUDE_LIBRARY #endif // INCLUDE_MAIN