結果
| 問題 |
No.950 行列累乗
|
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2019-12-10 05:59:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,024 bytes |
| コンパイル時間 | 1,116 ms |
| コンパイル使用メモリ | 110,096 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 17:21:00 |
| 合計ジャッジ時間 | 51,258 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 2 |
| other | AC * 15 RE * 42 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll p;
using arr=array<ll, 2>;
using Mat=array<arr, 2>;
Mat matmul(Mat a, Mat b){
Mat c={};
for(int i=0; i<2; i++){
for(int j=0; j<2; j++){
for(int k=0; k<2; k++){
(c[i][j]+=a[i][k]*b[k][j])%=p;
}
}
}
return c;
}
int main()
{
cin>>p;
Mat a, b;
cin>>a[0][0]>>a[0][1]>>a[1][0]>>a[1][1]>>b[0][0]>>b[0][1]>>b[1][0]>>b[1][1];
Mat ap=a;
for(int i=1; i<10000000; i++){
if(ap==b){
cout<<i<<endl;
return 0;
}
ap=matmul(ap, a);
}
assert(false);
return 0;
}
tempura_pp