結果

問題 No.2156 ぞい文字列
ユーザー ああいいああいい
提出日時 2022-12-11 13:57:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 54,512 KB
最終ジャッジ日時 2024-04-23 11:10:23
合計ジャッジ時間 1,689 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
54,164 KB
testcase_01 AC 37 ms
54,512 KB
testcase_02 AC 33 ms
53,016 KB
testcase_03 AC 34 ms
52,988 KB
testcase_04 AC 34 ms
53,244 KB
testcase_05 AC 37 ms
53,664 KB
testcase_06 AC 39 ms
54,296 KB
testcase_07 AC 38 ms
52,804 KB
testcase_08 AC 36 ms
52,832 KB
testcase_09 AC 37 ms
52,760 KB
testcase_10 AC 37 ms
52,592 KB
testcase_11 AC 37 ms
53,432 KB
testcase_12 AC 34 ms
53,796 KB
testcase_13 AC 33 ms
53,620 KB
testcase_14 AC 32 ms
53,296 KB
testcase_15 AC 33 ms
53,568 KB
testcase_16 AC 33 ms
52,632 KB
testcase_17 AC 33 ms
52,700 KB
testcase_18 AC 33 ms
52,124 KB
testcase_19 AC 32 ms
53,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

A = [[1,1],[1,0]]
P = 998244353

def seki(A,B):
    l = [[0] * 2 for _ in range(2)]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                l[i][j] += A[i][k] * B[k][j]
                l[i][j] %= P
    return l
u = N - 1
e = [[1,0],[0,1]]
while u:
    if u & 1:
        e = seki(e,A)
    A = seki(A,A)
    u >>= 1
ans = e[0][0] + e[1][0] - 1
#print(A)
print(ans % P)
0