結果
問題 | No.718 行列のできるフィボナッチ数列道場 (1) |
ユーザー | simamumu |
提出日時 | 2018-07-27 23:26:01 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 10,860 KB |
実行使用メモリ | 22,940 KB |
最終ジャッジ日時 | 2023-09-18 14:22:08 |
合計ジャッジ時間 | 6,486 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
ソースコード
from collections import defaultdict from itertools import product import sys,heapq,bisect,math,itertools,string sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 AtoZ = [chr(i) for i in range(65,65+26)] atoz = [chr(i) for i in range(97,97+26)] def mat2_mul(X, Y): Z = [ [0, 0], [0, 0] ] for (i,j,k) in product(range(2),range(2),range(2)): Z[i][j] += X[i][k] * Y[k][j] return Z def mat2_pow(X, n): if n == 0: return [ [1, 0], [0, 1] ] elif n % 2: return mat2_mul(X, mat2_pow(X, n-1)) else: half_pow = mat2_pow(X, n/2) return mat2_mul(half_pow, half_pow) def fib(n): if n == 0: return 0 else: F = [ [0, 1], [1, 1] ] return mat2_pow(F, n-1)[1][1] N = int(input()) print(fib(N)%mod*fib(N+1)%mod)