結果

問題 No.2156 ぞい文字列
ユーザー rlangevinrlangevin
提出日時 2023-08-22 12:57:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 86,336 KB
実行使用メモリ 71,428 KB
最終ジャッジ日時 2023-08-22 12:57:33
合計ジャッジ時間 4,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
70,936 KB
testcase_01 AC 72 ms
71,132 KB
testcase_02 AC 71 ms
71,160 KB
testcase_03 AC 71 ms
71,048 KB
testcase_04 AC 72 ms
71,088 KB
testcase_05 AC 70 ms
71,096 KB
testcase_06 AC 70 ms
71,104 KB
testcase_07 AC 72 ms
71,188 KB
testcase_08 AC 71 ms
71,428 KB
testcase_09 AC 72 ms
71,124 KB
testcase_10 AC 75 ms
71,132 KB
testcase_11 AC 73 ms
71,068 KB
testcase_12 AC 70 ms
71,064 KB
testcase_13 AC 73 ms
71,356 KB
testcase_14 AC 73 ms
71,184 KB
testcase_15 AC 72 ms
70,932 KB
testcase_16 AC 74 ms
71,076 KB
testcase_17 AC 76 ms
71,184 KB
testcase_18 AC 76 ms
71,368 KB
testcase_19 AC 75 ms
71,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def Matprod(A, B, mod, N):
    temp = [0] * N*N
    for i in range(N):
        for j in range(N):
            ij = i * N + j
            for k in range(N):
                temp[ij] += A[i*N+k] * B[k*N+j]
                temp[ij] %= mod
    return temp

def Matpow_Linear(A, M, mod, N):
    Mat = [0] * N*N
    for i in range(N):
        Mat[i*N+i] = 1
         
    while M:
        if M & 1:
            Mat = Matprod(Mat, A, mod, N)
        A = Matprod(A, A, mod, N)
        M >>= 1
    return Mat  

N = int(input())
A = [1, 1, 1, 0]
mod = 998244353
A = Matpow_Linear(A, N, mod, 2)
print((A[0] - 1) % mod)
0