結果

問題 No.2156 ぞい文字列
ユーザー 👑 H20H20
提出日時 2022-12-09 21:57:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 54,828 KB
最終ジャッジ日時 2024-04-22 22:03:37
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,376 KB
testcase_01 AC 38 ms
53,320 KB
testcase_02 AC 33 ms
53,212 KB
testcase_03 AC 33 ms
53,416 KB
testcase_04 AC 35 ms
53,004 KB
testcase_05 AC 34 ms
53,344 KB
testcase_06 AC 35 ms
54,828 KB
testcase_07 AC 34 ms
53,424 KB
testcase_08 AC 33 ms
53,380 KB
testcase_09 AC 35 ms
52,728 KB
testcase_10 AC 35 ms
53,344 KB
testcase_11 AC 32 ms
53,540 KB
testcase_12 AC 31 ms
53,420 KB
testcase_13 AC 33 ms
53,016 KB
testcase_14 AC 34 ms
52,684 KB
testcase_15 AC 32 ms
52,492 KB
testcase_16 AC 36 ms
52,616 KB
testcase_17 AC 33 ms
52,464 KB
testcase_18 AC 33 ms
53,076 KB
testcase_19 AC 33 ms
53,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
MOD = 998244353
def exp(mat_a, mat_b):
    new_mat = [[0]*len(mat_a) for _ in range(len(mat_a))]
    for i in range(len(mat_a)):
        for j in range(len(mat_a)):
            new_mat[i][j] = sum(mat_a[i][w]*mat_b[w][j] % MOD for w in range(len(mat_a))) % MOD
    return new_mat

ANS = [[1,0],[0,1]]
MAP = [[1,1],[1,0]]
K = N
while K:
    if K & 1:
        ANS = exp(ANS, MAP)
    MAP = exp(MAP, MAP)
    K //= 2
print((ANS[0][0]-1)%MOD)

0