結果

問題 No.1885 Flat Permutation
ユーザー rlangevinrlangevin
提出日時 2023-06-02 08:59:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 23,940 KB
最終ジャッジ日時 2023-08-28 02:17:49
合計ジャッジ時間 10,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
23,936 KB
testcase_01 AC 159 ms
23,912 KB
testcase_02 AC 156 ms
23,912 KB
testcase_03 AC 165 ms
23,796 KB
testcase_04 AC 158 ms
23,908 KB
testcase_05 AC 160 ms
23,864 KB
testcase_06 AC 154 ms
23,872 KB
testcase_07 AC 156 ms
23,868 KB
testcase_08 AC 172 ms
23,864 KB
testcase_09 AC 158 ms
23,940 KB
testcase_10 AC 167 ms
23,804 KB
testcase_11 AC 157 ms
23,868 KB
testcase_12 AC 172 ms
23,868 KB
testcase_13 AC 157 ms
23,824 KB
testcase_14 AC 160 ms
23,808 KB
testcase_15 AC 159 ms
23,824 KB
testcase_16 AC 161 ms
23,828 KB
testcase_17 AC 158 ms
23,796 KB
testcase_18 AC 164 ms
23,868 KB
testcase_19 AC 211 ms
23,876 KB
testcase_20 AC 210 ms
23,856 KB
testcase_21 AC 214 ms
23,856 KB
testcase_22 AC 211 ms
23,872 KB
testcase_23 AC 160 ms
23,928 KB
testcase_24 AC 157 ms
23,804 KB
testcase_25 AC 158 ms
23,800 KB
testcase_26 AC 160 ms
23,800 KB
testcase_27 AC 214 ms
23,892 KB
testcase_28 AC 225 ms
23,856 KB
testcase_29 AC 225 ms
23,888 KB
testcase_30 AC 213 ms
23,820 KB
testcase_31 AC 214 ms
23,868 KB
testcase_32 AC 161 ms
23,868 KB
testcase_33 AC 159 ms
23,812 KB
testcase_34 AC 159 ms
23,868 KB
testcase_35 AC 214 ms
23,800 KB
testcase_36 AC 214 ms
23,932 KB
testcase_37 AC 160 ms
23,864 KB
testcase_38 AC 161 ms
23,808 KB
testcase_39 AC 157 ms
23,796 KB
testcase_40 AC 174 ms
23,824 KB
testcase_41 AC 182 ms
23,904 KB
testcase_42 AC 174 ms
23,880 KB
testcase_43 AC 216 ms
23,828 KB
testcase_44 AC 218 ms
23,868 KB
testcase_45 AC 213 ms
23,808 KB
testcase_46 AC 230 ms
23,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, X, Y = map(int, input().split())
if X > Y:
    X, Y = Y, X
if X != 1:
    X += 1
if Y != N:
    Y -= 1
M = Y - X

mod = 998244353
n = 202020

fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

ans = 0
now = 0
while M >= 0:
    ans += comb(M + now, now)
    ans %= mod
    M -= 3
    now += 1
print(ans)
0