結果

問題 No.950 行列累乗
ユーザー tempura_pptempura_pp
提出日時 2019-12-10 05:56:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 108,604 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 21:58:31
合計ジャッジ時間 47,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
	}
	cout<<-1<<endl;
	return 0;
}
0