結果

問題 No.2141 Enumeratest
ユーザー 👑 H20H20
提出日時 2022-12-02 21:36:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 246,528 KB
最終ジャッジ日時 2024-04-18 05:22:26
合計ジャッジ時間 17,807 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
246,436 KB
testcase_01 AC 436 ms
246,144 KB
testcase_02 AC 464 ms
246,272 KB
testcase_03 AC 431 ms
246,144 KB
testcase_04 AC 435 ms
246,272 KB
testcase_05 AC 432 ms
246,272 KB
testcase_06 AC 431 ms
246,272 KB
testcase_07 AC 419 ms
246,272 KB
testcase_08 AC 416 ms
246,144 KB
testcase_09 AC 427 ms
246,400 KB
testcase_10 AC 432 ms
246,272 KB
testcase_11 AC 416 ms
246,144 KB
testcase_12 AC 420 ms
246,144 KB
testcase_13 AC 425 ms
246,144 KB
testcase_14 AC 430 ms
246,144 KB
testcase_15 AC 416 ms
246,144 KB
testcase_16 AC 421 ms
246,272 KB
testcase_17 AC 442 ms
246,144 KB
testcase_18 AC 436 ms
246,400 KB
testcase_19 AC 450 ms
246,144 KB
testcase_20 AC 445 ms
246,264 KB
testcase_21 AC 445 ms
246,400 KB
testcase_22 AC 451 ms
246,528 KB
testcase_23 AC 452 ms
246,272 KB
testcase_24 AC 450 ms
246,144 KB
testcase_25 AC 434 ms
246,400 KB
testcase_26 AC 439 ms
246,144 KB
testcase_27 AC 432 ms
246,400 KB
testcase_28 AC 447 ms
246,400 KB
testcase_29 AC 434 ms
246,400 KB
testcase_30 AC 444 ms
246,272 KB
testcase_31 AC 429 ms
246,400 KB
testcase_32 AC 452 ms
246,272 KB
testcase_33 AC 452 ms
246,144 KB
testcase_34 AC 469 ms
246,272 KB
testcase_35 AC 437 ms
246,144 KB
testcase_36 AC 444 ms
246,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#コンビネーション
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = 10**6*2+50
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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

ave =  M//N
m = M%N
nokori = M
ans = 1
for i in range(N):
    if m>i:
        ans = ans*cmb(nokori,ave+1,mod)%mod
        nokori-=ave+1
    else:
        ans = ans*cmb(nokori,ave,mod)%mod
        nokori-=ave
print(ans)
0