結果

問題 No.2791 Beginner Contest
ユーザー 2000 Ekiben2000 Ekiben
提出日時 2024-06-21 21:36:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-06-21 21:36:42
合計ジャッジ時間 7,008 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
    
    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.data[i]) % MOD
            i -= i & -i
        return s
    
    def add(self, i, x):
        while i <= self.n:
            self.data[i] = (self.data[i] + x) % MOD
            i += i & -i

MOD = 998244353

def cnt(N, K):
    bit = BIT(N + 1)
    bit.add(1, 1)  
    
    for i in range(1, N + 1):
        val = (bit.sum(i) - bit.sum(max(0, i - K + 1)) + MOD) % MOD
        bit.add(i + 1, val)
    
    return bit.sum(N + 1)
N, K = map(int, input().split())
result = cnt(N, K)
print(result)
0