結果

問題 No.303 割れません
ユーザー antaanta
提出日時 2015-11-14 01:25:34
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 387 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 100,944 KB
最終ジャッジ日時 2023-10-11 17:35:26
合計ジャッジ時間 12,375 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# ref: <http://ideone.com/398PRc>

def fib(n):
	if n == 0:
		return (1, 0)
	a, b = fib(n // 2)
	aa, bb, abab = a ** 2, b ** 2, (a+b) ** 2
	if n % 2 == 0:
		return (aa + bb, abab - aa)
	else:
		return (abab - aa, abab + bb)

n = int(input())
if n == 2:
	print('3\nINF\n')
else:
	if n % 2 == 1:
		ans = fib(n)[1]
	else:
		a, b = fib(n // 2)
		ans = a * b * 2
	print('%d\n%d\n' % (n, ans))
0