結果
| 問題 |
No.2084 Mex Subset For All Sequences
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-09 21:04:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,389 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 82,644 KB |
| 実行使用メモリ | 73,436 KB |
| 最終ジャッジ日時 | 2025-04-09 21:06:20 |
| 合計ジャッジ時間 | 4,319 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 19 |
ソースコード
MOD = 998244353
def main():
import sys
N, M = map(int, sys.stdin.readline().split())
if M == 0:
print(0)
return
max_m = M
# Precompute factorials and inverse factorials
max_fact = max(2*M, N)
fact = [1]*(max_fact+1)
inv_fact = [1]*(max_fact+1)
for i in range(1, max_fact+1):
fact[i] = fact[i-1] * i % MOD
inv_fact[max_fact] = pow(fact[max_fact], MOD-2, MOD)
for i in range(max_fact-1, -1, -1):
inv_fact[i] = inv_fact[i+1] * (i+1) % MOD
def comb(m, s):
if s < 0 or s > m:
return 0
return fact[m] * inv_fact[s] % MOD * inv_fact[m-s] % MOD
total = 0
# Process m from 1 to M-1
for m in range(1, M):
current = 0
x = 2 * M - 1
for s in range(0, m+1):
c = comb(m, s)
term = pow(x - s, N, MOD)
if s % 2 == 1:
term = (-term) % MOD
current = (current + c * term) % MOD
total = (total + m * current) % MOD
# Process m = M
m = M
current = 0
x = 2 * M
for s in range(0, m+1):
c = comb(m, s)
term = pow(x - s, N, MOD)
if s % 2 == 1:
term = (-term) % MOD
current = (current + c * term) % MOD
total = (total + m * current) % MOD
print(total % MOD)
if __name__ == '__main__':
main()
lam6er