// 実数における誤差評価による解法 #include #include #include #include using namespace std; #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 const 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 FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT template inline T Absolute( const T& a ){ return a > 0 ? a : -a; } inline CEXPR( int , bound_size , 15 ); inline CEXPR( double , epsilon , 0.00000001 ); // 標準エラー出力でデバッグ void Check( double ( &A )[bound_size][bound_size] , const int& L , const int& M ) { FOR( i , 0 , L ){ double ( &A_i )[bound_size] = A[i]; FOR( j , 0 , M ){ cerr << A_i[j] << ",\n"[j==M-1]; } } cerr << "\n"; return; } int Rank( double ( &A )[bound_size][bound_size] , const int& L , const int& M ) { int i_min = 0; int i_curr , i_curr_max; int j_curr = 0; while( i_min < L && j_curr < M ){ i_curr = i_curr_max = i_min; double A_ij_max = Absolute( A[i_curr_max][j_curr] ); while( i_curr++ < L ){ double A_ij_curr = Absolute( A[i_curr][j_curr] ); if( A_ij_max < A_ij_curr ){ A_ij_max = A_ij_curr; i_curr_max = i_curr; } } if( A_ij_max >= epsilon ){ swap( A[i_min] , A[i_curr_max] ); Check( A , L , M ); double ( &A_i_min )[bound_size] = A[i_min]; double A_ij_min_curr = A_i_min[j_curr]; FOR( j , j_curr , M ){ A_i_min[j] /= A_ij_min_curr; } FOR( i , i_min + 1 , L ){ double ( &A_i )[bound_size] = A[i]; double A_ij_curr = A_i[j_curr]; FOR( j , j_curr , M ){ A_i[j] -= A_ij_curr * A_i_min[j]; } } Check( A , L , M ); i_min++; } j_curr++; } return i_min; } int main() { UNTIE; CIN_ASSERT( L , 1 , bound_size ); CIN_ASSERT( M , 1 , bound_size / L ); CIN_ASSERT( N , 1 , bound_size / M ); CEXPR( int , bound , 6 ); double A[bound_size][bound_size]; FOR( i , 0 , L ){ double ( &Ai )[bound_size] = A[i]; FOR( j , 0 , M ){ CIN_ASSERT( Aij , - bound , bound ); Ai[j] = Aij; } } double B[bound_size][bound_size]; FOR( j , 0 , M ){ double ( &Bj )[bound_size] = B[j]; FOR( k , 0 , N ){ CIN_ASSERT( Bjk , - bound , bound ); Bj[k] = Bjk; } } double sum = 0; FOR( i , 0 , L ){ double ( &Ai )[bound_size] = A[i]; FOR( k , 0 , N ){ FOR( j , 0 , M ){ sum += Ai[j] * B[j][k]; } if( Absolute( sum ) >= epsilon ){ RETURN( "No" ); } } } int rankA = Rank( A , L , M ); int rankB = Rank( B , M , N ); RETURN( rankB == M - rankA ? "Yes" : "No" ); }