結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
81,048 KB
testcase_01 AC 84 ms
78,132 KB
testcase_02 AC 100 ms
79,136 KB
testcase_03 AC 127 ms
79,592 KB
testcase_04 AC 1,356 ms
82,844 KB
testcase_05 AC 1,579 ms
83,648 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
import sys
if sys.version_info[0]>=3: xrange=range

M=17
def mul(a,b):
	r=[[0]*len(b[0]) for _ in xrange(len(a))]
	for y in xrange(len(a)):
		for x in xrange(len(b[0])):
			r[y][x]=sum(a[y][i]*b[i][x] for i in xrange(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 xrange(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