結果

問題 No.303 割れません
ユーザー pluto77pluto77
提出日時 2018-01-05 11:02:53
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 5,630 ms / 10,000 ms
コード長 416 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 77,444 KB
実行使用メモリ 177,524 KB
最終ジャッジ日時 2023-08-24 20:14:32
合計ジャッジ時間 48,747 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
76,092 KB
testcase_01 AC 72 ms
76,348 KB
testcase_02 AC 72 ms
76,424 KB
testcase_03 AC 1,761 ms
105,408 KB
testcase_04 AC 5,630 ms
177,264 KB
testcase_05 AC 5,560 ms
177,308 KB
testcase_06 AC 5,529 ms
177,368 KB
testcase_07 AC 4,221 ms
158,436 KB
testcase_08 AC 4,535 ms
159,000 KB
testcase_09 AC 4,467 ms
159,336 KB
testcase_10 AC 74 ms
76,424 KB
testcase_11 AC 5,629 ms
177,524 KB
testcase_12 AC 4,571 ms
158,328 KB
testcase_13 AC 1,587 ms
129,400 KB
testcase_14 AC 849 ms
97,248 KB
testcase_15 AC 495 ms
89,200 KB
testcase_16 AC 73 ms
76,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_303

def mul(a,b):
 return [a[0]*b[0]+a[1]*b[2],
         a[0]*b[1]+a[1]*b[3],
         a[2]*b[0]+a[3]*b[2],
         a[2]*b[1]+a[3]*b[3]]

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]

l=int(raw_input())
if l==2:
 print 3
 print 'INF'
else:
 print l
 res=fib(l)
 if l%2==0:
  res-=fib(l/2)**2
 print res
0