結果

問題 No.303 割れません
ユーザー chocoruskchocorusk
提出日時 2019-12-29 13:32:08
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 560 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 186,496 KB
最終ジャッジ日時 2024-04-23 14:02:03
合計ジャッジ時間 23,428 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
52,096 KB
testcase_01 AC 53 ms
52,224 KB
testcase_02 AC 45 ms
51,968 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 41 ms
52,096 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 42 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
l=int(input())
if l==2:
  print(3)
  print("INF")
  sys.exit()
print(l)
a=[[0,1],[1,1]]
def fib(n):
  ap=a
  b=[[1,0],[0,1]]
  while n>0:
    if n&1:
      c=[[0,0],[0,0]]
      for i in range(2):
        for j in range(2):
          for k in range(2):
            c[i][j]+=b[i][k]*ap[k][j]
      b=c
    c=[[0,0],[0,0]]
    for i in range(2):
      for j in range(2):
        for k in range(2):
          c[i][j]+=ap[i][k]*ap[k][j]
    ap=c
    n>>=1
  return b[0][0]+b[0][1]
if l%2==0:
  x=fib(l//2-1)
  print(fib(l-1)-x*x)
else:
  print(fib(l-1))
0