結果
問題 |
No.658 テトラナッチ数列 Hard
|
ユーザー |
![]() |
提出日時 | 2020-06-15 23:25:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 756 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 44,624 KB |
最終ジャッジ日時 | 2024-07-03 11:37:32 |
合計ジャッジ時間 | 6,312 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 8 |
ソースコード
#Fibonacchi sequence import numpy as np import sys input = sys.stdin.readline def mat_f(X): if X == 0: return np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) elif X == 1: return A else: if X % 2 == 0: S = mat_f(X//2) return np.dot(S, S) % mod else: S = mat_f(X//2) return np.dot(np.dot(S, S), A) % mod def main(): A = np.array([[1, 1, 1, 1], [1, 0, 0, 0], [ 0, 1, 0, 0], [0, 0, 1, 0]]) mod = 17 Q = int(input()) d = [int(input()) for i in range(Q)] for i in range(Q): K = np.dot(mat_f(d[i]-1), np.array([1, 0, 0, 0])) ans = (K[-1]) % mod print(ans) if __name__ == "__main__": main()