結果

問題 No.718 行列のできるフィボナッチ数列道場 (1)
ユーザー pluto77pluto77
提出日時 2018-08-13 08:15:34
言語 Python2
(2.7.18)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 7,048 KB
実行使用メモリ 6,368 KB
最終ジャッジ日時 2023-10-24 16:27:35
合計ジャッジ時間 1,088 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,368 KB
testcase_01 AC 10 ms
6,368 KB
testcase_02 AC 10 ms
6,368 KB
testcase_03 AC 10 ms
6,368 KB
testcase_04 AC 10 ms
6,368 KB
testcase_05 AC 10 ms
6,368 KB
testcase_06 AC 10 ms
6,368 KB
testcase_07 AC 11 ms
6,368 KB
testcase_08 AC 11 ms
6,368 KB
testcase_09 AC 11 ms
6,368 KB
testcase_10 AC 10 ms
6,368 KB
testcase_11 AC 10 ms
6,368 KB
testcase_12 AC 10 ms
6,368 KB
testcase_13 AC 11 ms
6,368 KB
testcase_14 AC 11 ms
6,368 KB
testcase_15 AC 10 ms
6,368 KB
testcase_16 AC 10 ms
6,368 KB
testcase_17 AC 10 ms
6,368 KB
testcase_18 AC 10 ms
6,368 KB
testcase_19 AC 11 ms
6,368 KB
testcase_20 AC 9 ms
6,368 KB
testcase_21 AC 10 ms
6,368 KB
testcase_22 AC 10 ms
6,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki718

mod=10**9+7
def mul(a,b):
 return [(a[0]*b[0]+a[1]*b[2])%mod,
         (a[0]*b[1]+a[1]*b[3])%mod,
         (a[2]*b[0]+a[3]*b[2])%mod,
         (a[2]*b[1] + a[3]*b[3])%mod]

def fib(n):
 if n<=1:
  return n
 res=[1,0,0,1]
 mx=[1,1,1,0]
 while n>0:
  if n%2:
   res=mul(mx,res)
  mx=mul(mx,mx)
  n/=2
 return res[2]%mod

N=int(raw_input())
print (fib(N)*fib(N+1))%mod
0