結果

問題 No.1885 Flat Permutation
ユーザー rlangevinrlangevin
提出日時 2023-06-02 08:54:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 79,472 KB
最終ジャッジ日時 2023-08-28 02:17:39
合計ジャッジ時間 7,918 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
79,060 KB
testcase_01 AC 83 ms
78,912 KB
testcase_02 AC 83 ms
78,924 KB
testcase_03 AC 87 ms
79,228 KB
testcase_04 AC 83 ms
79,164 KB
testcase_05 AC 82 ms
79,040 KB
testcase_06 AC 82 ms
78,940 KB
testcase_07 AC 81 ms
79,088 KB
testcase_08 AC 82 ms
78,988 KB
testcase_09 AC 83 ms
79,084 KB
testcase_10 AC 86 ms
79,056 KB
testcase_11 AC 85 ms
79,004 KB
testcase_12 AC 84 ms
78,912 KB
testcase_13 AC 84 ms
79,020 KB
testcase_14 AC 84 ms
79,132 KB
testcase_15 AC 82 ms
78,964 KB
testcase_16 AC 82 ms
79,156 KB
testcase_17 AC 82 ms
79,052 KB
testcase_18 AC 84 ms
79,096 KB
testcase_19 AC 91 ms
79,260 KB
testcase_20 AC 90 ms
79,428 KB
testcase_21 AC 93 ms
79,388 KB
testcase_22 AC 91 ms
79,264 KB
testcase_23 AC 82 ms
79,128 KB
testcase_24 AC 82 ms
78,912 KB
testcase_25 AC 83 ms
78,912 KB
testcase_26 AC 84 ms
79,068 KB
testcase_27 AC 93 ms
79,332 KB
testcase_28 AC 90 ms
79,268 KB
testcase_29 AC 92 ms
79,364 KB
testcase_30 AC 93 ms
79,308 KB
testcase_31 AC 93 ms
79,280 KB
testcase_32 AC 81 ms
78,968 KB
testcase_33 AC 80 ms
78,960 KB
testcase_34 AC 81 ms
78,980 KB
testcase_35 AC 90 ms
79,288 KB
testcase_36 AC 90 ms
79,052 KB
testcase_37 AC 83 ms
79,024 KB
testcase_38 AC 84 ms
79,012 KB
testcase_39 AC 84 ms
79,080 KB
testcase_40 AC 86 ms
79,472 KB
testcase_41 AC 86 ms
79,264 KB
testcase_42 AC 87 ms
79,308 KB
testcase_43 AC 95 ms
79,184 KB
testcase_44 AC 92 ms
79,300 KB
testcase_45 AC 94 ms
79,252 KB
testcase_46 AC 93 ms
79,320 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