結果

問題 No.303 割れません
ユーザー 👑 rin204rin204
提出日時 2022-11-03 17:34:19
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 652 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 156,356 KB
最終ジャッジ日時 2023-09-25 01:55:23
合計ジャッジ時間 29,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

n = int(input())
if n == 2:
    print("INF")
    print(0)
    exit()
print(n)
def matpow(A, B, w):
    l = len(A)
    while w:
        if w & 1:
            C = [0] * l
            for i in range(l):
                for j in range(l):
                    C[i] += A[i][j] * B[j]
            B = C
        C = [[0] * l for _ in range(l)]
        for i in range(l):
            for j in range(l):
                for k in range(l):
                    C[i][j] += A[i][k] * A[k][j]
        A = C
        w >>= 1
    return B

A = [[1, 1], [1, 0]]
B = [1, 0]
ans = matpow(A, B, n - 1)[0]
if n % 2 == 0:
    ans -= matpow(A, B, n // 2 - 1)[0] ** 2
print(ans)
0