// 誤解法(乱択解)チェック #pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #include #include #include #include #include #include #include using namespace std; using ll = long long; #define MAIN main #define TYPE_OF( VAR ) remove_const::type >::type #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define COUT( ANSWER ) cout << ( ANSWER ) << "\n" #define SET_PRECISION( PRECISION ) cout << fixed << setprecision( PRECISION ) template inline T Absolute( const T& a ){ return a > 0 ? a : -a; } template class TwoByTwoMatrix { public: T m_M00; T m_M01; T m_M10; T m_M11; public: inline TwoByTwoMatrix( const T& M00 , const T& M01 , const T& M10 , const T& M11 ) noexcept; inline TwoByTwoMatrix& operator=( const TwoByTwoMatrix& mat ) noexcept; inline TwoByTwoMatrix operator*( const TwoByTwoMatrix& mat ); }; template inline TwoByTwoMatrix::TwoByTwoMatrix( const T& M00 , const T& M01 , const T& M10 , const T& M11 ) noexcept : m_M00( M00 ) , m_M01( M01 ) , m_M10( M10 ) , m_M11( M11 ) {} template inline TwoByTwoMatrix& TwoByTwoMatrix::operator=( const TwoByTwoMatrix& mat ) noexcept { if( &mat != this ){ m_M00 = mat.m_M00; m_M01 = mat.m_M01; m_M10 = mat.m_M10; m_M11 = mat.m_M11; } return *this; } template inline TwoByTwoMatrix TwoByTwoMatrix::operator*( const TwoByTwoMatrix& mat ) { return TwoByTwoMatrix ( m_M00 * mat.m_M00 + m_M01 * mat.m_M10 , m_M00 * mat.m_M01 + m_M01 * mat.m_M11 , m_M10 * mat.m_M00 + m_M11 * mat.m_M10 , m_M10 * mat.m_M01 + m_M11 * mat.m_M11 ); } int MAIN() { UNTIE; CEXPR( double , epsilon , 0.001 ); // CEXPR( int , d , 1000000 ); // CEXPR( int , d , 430000 ); CEXPR( int , d , 100000 ); CEXPR( int , d2 , d << 1 ); CEXPR( double , div , 100000.0 ); CEXPR( int , bound_T , 100000 ); CIN_ASSERT( T , 1 , bound_T ); REPEAT( T ){ CIN( double , M00 ); CIN( double , M01 ); CIN( double , M10 ); CIN( double , M11 ); TwoByTwoMatrix N{ 0 , 0 , 0 , 0 }; TwoByTwoMatrix N3{ 0 , 0 , 0 , 0 }; double N00 , N01 , N10 , N11; random_device rd{}; while( true ){ N.m_M00 = ( rd() % d2 - d ) / div; N.m_M01 = ( rd() % d2 - d ) / div; N.m_M10 = ( rd() % d2 - d ) / div; N.m_M11 = ( rd() % d2 - d ) / div; N3 = N * N * N; if( Absolute( N3.m_M00 - M00 ) <= epsilon && Absolute( N3.m_M01 - M01 ) <= epsilon && Absolute( N3.m_M10 - M10 ) <= epsilon && Absolute( N3.m_M11 - M11 ) <= epsilon ){ SET_PRECISION( 5 ); cout << N.m_M00 << " " << N.m_M01 << "\n"; cout << N.m_M10 << " " << N.m_M11 << "\n"; QUIT; } } } QUIT; }