結果

問題 No.2060 AND Sequence
ユーザー dachengzdachengz
提出日時 2022-11-16 06:21:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 53,432 KB
最終ジャッジ日時 2023-10-17 05:56:47
合計ジャッジ時間 4,301 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,432 KB
testcase_01 AC 33 ms
53,432 KB
testcase_02 AC 35 ms
53,432 KB
testcase_03 AC 33 ms
53,432 KB
testcase_04 AC 33 ms
53,432 KB
testcase_05 AC 33 ms
53,432 KB
testcase_06 AC 32 ms
53,432 KB
testcase_07 AC 31 ms
53,432 KB
testcase_08 AC 35 ms
53,432 KB
testcase_09 AC 33 ms
53,432 KB
testcase_10 AC 35 ms
53,432 KB
testcase_11 AC 35 ms
53,432 KB
testcase_12 AC 38 ms
53,432 KB
testcase_13 AC 37 ms
53,432 KB
testcase_14 AC 37 ms
53,432 KB
testcase_15 AC 37 ms
53,432 KB
testcase_16 AC 34 ms
53,432 KB
testcase_17 AC 34 ms
53,432 KB
testcase_18 AC 34 ms
53,432 KB
testcase_19 AC 35 ms
53,432 KB
testcase_20 AC 33 ms
53,432 KB
testcase_21 AC 33 ms
53,432 KB
testcase_22 AC 33 ms
53,432 KB
testcase_23 AC 35 ms
53,432 KB
testcase_24 AC 37 ms
53,432 KB
testcase_25 AC 36 ms
53,432 KB
testcase_26 AC 34 ms
53,432 KB
testcase_27 AC 34 ms
53,432 KB
testcase_28 AC 33 ms
53,432 KB
testcase_29 AC 33 ms
53,432 KB
testcase_30 AC 34 ms
53,432 KB
testcase_31 AC 34 ms
53,432 KB
testcase_32 AC 33 ms
53,432 KB
testcase_33 AC 34 ms
53,432 KB
testcase_34 AC 36 ms
53,432 KB
testcase_35 AC 35 ms
53,432 KB
testcase_36 AC 36 ms
53,432 KB
testcase_37 AC 34 ms
53,432 KB
testcase_38 AC 35 ms
53,432 KB
testcase_39 AC 36 ms
53,432 KB
testcase_40 AC 36 ms
53,432 KB
testcase_41 AC 35 ms
53,432 KB
testcase_42 AC 37 ms
53,432 KB
testcase_43 AC 39 ms
53,432 KB
testcase_44 AC 40 ms
53,432 KB
testcase_45 AC 37 ms
53,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

mod = 998244353

fac = [1] * 31
for i in range(2, 31):
    fac[i] = fac[i - 1] * i % mod
caf = [1] * 31
caf[30] = pow(fac[30], mod - 2, mod)
for i in range(30, 2, -1):
    caf[i - 1] = caf[i] * i % mod

def comb(n, k):
    if n < k or k < 0 or n < 0:
        return 0
    return fac[n] * caf[k] % mod * caf[n - k] % mod

M += 1
cnt = [0] * 31
prefix = 0
tot = 0
for e in range(30, -1, -1):
    if M & (1 << e):
        tot += 1 << e
        for i in range(e + 1):
            cnt[prefix + i] += comb(e, i)
        prefix += 1
    assert sum(cnt) == tot

ans = 0
Npow = 1
for i in range(31):
    ans = (ans + cnt[i] * Npow) % mod
    Npow = Npow * N % mod

print(ans)
0