結果

問題 No.1785 Inequality Signs
ユーザー mkawa2mkawa2
提出日時 2021-12-14 09:11:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 1,614 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 85,844 KB
実行使用メモリ 93,004 KB
最終ジャッジ日時 2023-09-30 16:51:03
合計ジャッジ時間 10,957 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
90,900 KB
testcase_01 AC 126 ms
91,572 KB
testcase_02 AC 202 ms
92,948 KB
testcase_03 AC 231 ms
90,792 KB
testcase_04 AC 101 ms
90,784 KB
testcase_05 AC 156 ms
92,432 KB
testcase_06 AC 220 ms
91,316 KB
testcase_07 AC 104 ms
90,948 KB
testcase_08 AC 216 ms
91,152 KB
testcase_09 AC 122 ms
91,596 KB
testcase_10 AC 186 ms
92,892 KB
testcase_11 AC 125 ms
91,676 KB
testcase_12 AC 150 ms
92,020 KB
testcase_13 AC 119 ms
91,524 KB
testcase_14 AC 163 ms
92,568 KB
testcase_15 AC 152 ms
92,096 KB
testcase_16 AC 141 ms
92,004 KB
testcase_17 AC 186 ms
92,856 KB
testcase_18 AC 188 ms
93,004 KB
testcase_19 AC 169 ms
92,440 KB
testcase_20 AC 176 ms
92,608 KB
testcase_21 AC 169 ms
92,548 KB
testcase_22 AC 124 ms
91,456 KB
testcase_23 AC 139 ms
92,012 KB
testcase_24 AC 233 ms
90,944 KB
testcase_25 AC 152 ms
92,124 KB
testcase_26 AC 150 ms
91,828 KB
testcase_27 AC 237 ms
90,928 KB
testcase_28 AC 237 ms
90,924 KB
testcase_29 AC 234 ms
90,788 KB
testcase_30 AC 235 ms
91,308 KB
testcase_31 AC 237 ms
90,844 KB
testcase_32 AC 236 ms
91,132 KB
testcase_33 AC 94 ms
90,812 KB
testcase_34 AC 102 ms
91,368 KB
testcase_35 AC 102 ms
91,552 KB
testcase_36 AC 169 ms
90,836 KB
testcase_37 AC 110 ms
90,948 KB
testcase_38 AC 113 ms
91,156 KB
testcase_39 AC 116 ms
91,416 KB
testcase_40 AC 125 ms
92,132 KB
testcase_41 AC 134 ms
92,984 KB
testcase_42 AC 178 ms
91,124 KB
testcase_43 AC 222 ms
91,008 KB
testcase_44 AC 201 ms
91,100 KB
testcase_45 AC 113 ms
92,344 KB
testcase_46 AC 115 ms
91,092 KB
testcase_47 AC 115 ms
92,568 KB
testcase_48 AC 137 ms
92,812 KB
testcase_49 AC 98 ms
91,028 KB
testcase_50 AC 200 ms
90,888 KB
testcase_51 AC 111 ms
91,308 KB
testcase_52 AC 107 ms
91,012 KB
testcase_53 AC 114 ms
91,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

def nHr(hn, hr):
    return nCr(hn+hr-1, hr-1)

def nPr(com_n, com_r):
    if com_r < 0: return 0
    if com_n < com_r: return 0
    return fac[com_n]*ifac[com_n-com_r]%md

def nCr(com_n, com_r):
    if com_r < 0: return 0
    if com_n < com_r: return 0
    return fac[com_n]*ifac[com_r]%md*ifac[com_n-com_r]%md

# 準備
n_max = 200005
fac = [1]
for i in range(1, n_max+1): fac.append(fac[-1]*i%md)
ifac = [1]*(n_max+1)
ifac[n_max] = pow(fac[n_max], md-2, md)
for i in range(n_max-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%md

n, k = LI()

si = 1
for i in range(n):
    si = si*(n+k-i)%md
c = si*ifac[n]%md

ans = 0
for i in range(n):
    if k-1-i < 0: break
    if k-1-i == 0:
        c = 1
    else:
        c = c*(k-i)%md*pow(n+k-i, md-2, md)%md
    ans += c*nCr(n-1, i)%md
    # pDB(c, nCr(n+k-1-i, n), n+k-1-i, n)
    # ans += nCr(n+k-1-i, n)*nCr(n-1, i)%md
    ans %= md
print(ans)
0