結果

問題 No.303 割れません
ユーザー 👑 rin204rin204
提出日時 2022-11-03 17:36:46
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 652 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 156,596 KB
最終ジャッジ日時 2023-09-25 01:57:46
合計ジャッジ時間 28,541 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,272 KB
testcase_01 AC 74 ms
71,408 KB
testcase_02 AC 73 ms
71,528 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 70 ms
71,624 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 71 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 2:
    print(3)
    print("INF")
    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