結果

問題 No.2299 Antitypoglycemia
ユーザー FromBooska
提出日時 2023-05-12 21:58:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 58,752 KB
最終ジャッジ日時 2024-11-28 18:14:20
合計ジャッジ時間 2,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# 包除原理だな

mod = 998244353
N, A, B = map(int, input().split())

if A != B:
    total = 1
    for i in range(1, N+1):
        total *= i
        total %= mod
    deduct1 = 1
    for i in range(1, N):
        deduct1 *= i
        deduct1 %= mod
    add1 = 1
    for i in range(1, N-1):
        add1 *= i
        add1 %= mod    
    ans = (total - deduct1*2 + add1)%mod
    #print(total, deduct1, add1)
    print(ans)
elif A == B:
    total = 1
    for i in range(1, N+1):
        total *= i
        total %= mod
    deduct1 = 1
    for i in range(1, N):
        deduct1 *= i
        deduct1 %= mod
    add1 = 0
    ans = (total - deduct1*2 + add1)%mod
    #print(total, deduct1, add1)
    print(ans)    
0