結果

問題 No.2199 lower_bound and upper_bound
ユーザー tassei903tassei903
提出日時 2023-01-20 23:41:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 97,824 KB
最終ジャッジ日時 2023-09-05 16:08:19
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
91,300 KB
testcase_01 AC 95 ms
91,008 KB
testcase_02 AC 110 ms
91,572 KB
testcase_03 AC 99 ms
91,536 KB
testcase_04 AC 97 ms
91,396 KB
testcase_05 AC 97 ms
91,060 KB
testcase_06 AC 98 ms
91,540 KB
testcase_07 AC 97 ms
91,484 KB
testcase_08 AC 96 ms
91,252 KB
testcase_09 AC 94 ms
91,392 KB
testcase_10 AC 104 ms
91,572 KB
testcase_11 AC 100 ms
91,100 KB
testcase_12 AC 97 ms
91,388 KB
testcase_13 AC 109 ms
93,344 KB
testcase_14 AC 100 ms
91,112 KB
testcase_15 AC 98 ms
91,056 KB
testcase_16 AC 111 ms
95,196 KB
testcase_17 AC 110 ms
96,264 KB
testcase_18 AC 110 ms
94,952 KB
testcase_19 AC 107 ms
93,324 KB
testcase_20 AC 115 ms
97,824 KB
testcase_21 AC 107 ms
92,844 KB
testcase_22 AC 112 ms
94,860 KB
testcase_23 AC 112 ms
95,768 KB
testcase_24 AC 114 ms
95,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n,l,r = na()
mod = 998244353
nn = 1000000
fact = [1] * nn
for i in range(nn - 1):
    fact[i + 1] = fact[i] * (i + 1) % mod
invfact = [1] * nn
invfact[nn - 1] = pow(fact[nn - 1], mod - 2, mod)
for i in range(nn - 1)[::-1]:
    invfact[i] = invfact[i + 1] * (i + 1) % mod
 
def binom(x, y):
    if x < 0 or y < 0 or x - y < 0:
        return 0
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod


ans = 0
for i in range(r-l+1):
    tx,ty = n, r-i+n
    sx,sy = 1, 0
    ssx, ssy = -r-1, r+2
    #print(tx-sx,ty-sy,tx-ssx, ty-ssy,binom(ty-sy+tx-sx,tx-sx),binom(ty-ssy+tx-ssx,tx-ssx))
    ans += binom(ty-sy+tx-sx,tx-sx)-binom(ty-ssy+tx-ssx,tx-ssx)
    ans %= mod
print(ans)
0