結果
| 問題 |
No.2447 行列累乗根
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-04-07 14:53:24 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,457 bytes |
| コンパイル時間 | 4,665 ms |
| コンパイル使用メモリ | 135,976 KB |
| 最終ジャッジ日時 | 2025-02-11 23:37:45 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 28 |
ソースコード
// 誤解法(乱択解)チェック
#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>
#include <string>
#include <iomanip>
#include <random>
using namespace std;
using ll = long long;
#define MAIN main
#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::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 <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : -a; }
template <typename T>
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<T>& operator=( const TwoByTwoMatrix<T>& mat ) noexcept;
inline TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat );
};
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> inline 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 )
{
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;
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<double> N{ 0 , 0 , 0 , 0 };
TwoByTwoMatrix<double> 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;
}