結果

問題 No.303 割れません
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-14 19:16:56
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 484 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 148,172 KB
最終ジャッジ日時 2024-04-09 22:25:01
合計ジャッジ時間 12,107 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
52,364 KB
testcase_01 AC 31 ms
52,536 KB
testcase_02 AC 32 ms
52,400 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 32 ms
52,660 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 35 ms
52,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#https://ncode.syosetu.com/n4830bu/303/
def maine(L):
    if L <= 2:
        return 1
    L -= 2
    a,b,c,d,maine,book = 1,1,1,0,1,1
    while L > 0:
        if L%2 == 1:
            maine,book = a*maine+b*book, c*maine+d*book
        a,b,c,d = a**2+b*c, b*(a+d), c*(a+d), b*c+d**2
        L //= 2
    return maine

L = int(input())
if L==2:
    print(3)
    print("INF")
else:
    print(L)
    if L&1 == 1: 
        print(maine(L))
    else:
        print(maine(L) - maine(L//2)**2)
0