結果

問題 No.658 テトラナッチ数列 Hard
ユーザー cielciel
提出日時 2017-12-28 00:42:07
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 451 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 77,436 KB
実行使用メモリ 89,584 KB
最終ジャッジ日時 2023-08-23 07:33:44
合計ジャッジ時間 14,440 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,524 KB
testcase_01 AC 84 ms
78,192 KB
testcase_02 AC 102 ms
79,020 KB
testcase_03 AC 121 ms
79,524 KB
testcase_04 AC 1,246 ms
82,928 KB
testcase_05 AC 1,383 ms
82,684 KB
testcase_06 AC 1,769 ms
84,412 KB
testcase_07 AC 1,932 ms
83,356 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
import sys
M=17
def mul(a,b):
	r=[[0]*len(b[0]) for _ in range(len(a))]
	for y in range(len(a)):
		for x in range(len(b[0])):
			r[y][x]=sum(a[y][i]*b[i][x] for i in range(len(b)))%M
	return r

A=[[1,1,1,1],[1,0,0,0],[0,1,0,0],[0,0,1,0]]
E=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
for _ in range(int(sys.stdin.readline())):
	n=int(sys.stdin.readline())
	a=A
	e=E
	while n:
		if n%2: e=mul(a,e)
		a=mul(a,a)
		n//=2
	print(e[-1][-1])
0