結果

問題 No.950 行列累乗
ユーザー tempura_pptempura_pp
提出日時 2019-12-10 05:59:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,024 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 109,884 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 22:01:55
合計ジャッジ時間 8,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 2 ms
4,380 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
4,376 KB
testcase_06 RE -
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 22 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 RE -
testcase_13 AC 329 ms
4,380 KB
testcase_14 AC 888 ms
4,376 KB
testcase_15 RE -
testcase_16 AC 14 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 RE -
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 AC 1 ms
4,376 KB
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 RE -
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 2 ms
4,384 KB
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0