結果
問題 | No.2441 行列累乗 |
ユーザー |
👑 |
提出日時 | 2023-05-17 14:02:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,227 bytes |
コンパイル時間 | 959 ms |
コンパイル使用メモリ | 74,600 KB |
最終ジャッジ日時 | 2025-02-13 01:04:19 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#pragma GCC optimize ( "O3" )#pragma GCC optimize( "unroll-loops" )#pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )#include <iostream>#include <stdio.h>#include <stdint.h>#include <cassert>using namespace std;#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr )#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 QUIT return 0#define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT#define MAIN maintemplate <typename T>class TwoByTwoMatrix{public:// private: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;TwoByTwoMatrix<T>& operator=( const TwoByTwoMatrix<T>& mat ) noexcept;inline TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat ) const noexcept;};template <typename T> inline TwoByTwoMatrix<T>::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 <typename T>TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator=( const TwoByTwoMatrix<T>& 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 <typename T> inline TwoByTwoMatrix<T> TwoByTwoMatrix<T>::operator*( const TwoByTwoMatrix<T>& mat ) const noexcept { return TwoByTwoMatrix<T>(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;constexpr const int bound = 100;CIN_ASSERT( M11 , - bound , bound );CIN_ASSERT( M12 , - bound , bound );CIN_ASSERT( M21 , - bound , bound );CIN_ASSERT( M22 , - bound , bound );TwoByTwoMatrix<int> M{ M11 , M12 , M21 , M22 };TwoByTwoMatrix<int> M3 = M * M * M;cout << M3.m_M00 << " " << M3.m_M01 << "\n";cout << M3.m_M10 << " " << M3.m_M11 << "\n";QUIT;}