結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー flygonflygon
提出日時 2022-11-25 21:26:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 86,316 KB
最終ジャッジ日時 2024-04-10 02:37:12
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,908 KB
testcase_01 AC 47 ms
55,432 KB
testcase_02 AC 46 ms
56,292 KB
testcase_03 WA -
testcase_04 AC 43 ms
55,052 KB
testcase_05 AC 43 ms
55,784 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 43 ms
55,624 KB
testcase_09 AC 43 ms
54,768 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 43 ms
54,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 43 ms
55,172 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 43 ms
55,236 KB
testcase_29 WA -
testcase_30 AC 43 ms
54,720 KB
testcase_31 WA -
testcase_32 AC 42 ms
55,260 KB
testcase_33 WA -
testcase_34 AC 48 ms
55,044 KB
testcase_35 WA -
testcase_36 AC 46 ms
55,304 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
mod = 998244353

n = int(input())
m = int(input())
ans = pow(2, n, mod)
if m > n:
  print(0)
  exit()
#nCk
def com(n,mod):
  fact = [1,1]
  factinv = [1,1]
  inv = [0,1]
  for i in range(2,n+1):
    fact.append((fact[-1]*i)%mod)
    inv.append((-inv[mod%i]*(mod//i))%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)
  return fact, factinv

f,fi = com(m+10, mod)

ue = m

for i in range(m):
  tmp = ue * fi[i] % mod
  ans -= tmp
  ans %= mod
  ue *= m-i
  ue %= mod

print(ans)
0