結果

問題 No.303 割れません
ユーザー 👑 rin204rin204
提出日時 2023-07-04 23:46:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,026 ms / 10,000 ms
コード長 703 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 170,600 KB
最終ジャッジ日時 2023-09-25 23:03:41
合計ジャッジ時間 34,749 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,316 KB
testcase_01 AC 71 ms
71,176 KB
testcase_02 AC 73 ms
71,276 KB
testcase_03 AC 1,327 ms
99,312 KB
testcase_04 AC 4,026 ms
170,400 KB
testcase_05 AC 3,981 ms
170,600 KB
testcase_06 AC 3,928 ms
170,392 KB
testcase_07 AC 3,031 ms
151,716 KB
testcase_08 AC 3,300 ms
151,236 KB
testcase_09 AC 3,241 ms
151,884 KB
testcase_10 AC 76 ms
71,168 KB
testcase_11 AC 4,004 ms
170,204 KB
testcase_12 AC 3,267 ms
151,188 KB
testcase_13 AC 1,309 ms
113,932 KB
testcase_14 AC 709 ms
91,552 KB
testcase_15 AC 431 ms
80,916 KB
testcase_16 AC 72 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


sys.set_int_max_str_digits(10 ** 9)


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