結果

問題 No.1785 Inequality Signs
ユーザー titiatitia
提出日時 2021-12-25 05:39:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,161 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 11,812 KB
実行使用メモリ 33,616 KB
最終ジャッジ日時 2023-10-20 11:03:02
合計ジャッジ時間 35,132 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
33,616 KB
testcase_01 AC 364 ms
33,616 KB
testcase_02 AC 881 ms
33,616 KB
testcase_03 AC 1,121 ms
33,616 KB
testcase_04 AC 225 ms
33,616 KB
testcase_05 AC 598 ms
33,616 KB
testcase_06 AC 1,030 ms
33,616 KB
testcase_07 AC 244 ms
33,616 KB
testcase_08 AC 995 ms
33,616 KB
testcase_09 AC 349 ms
33,616 KB
testcase_10 AC 776 ms
33,616 KB
testcase_11 AC 392 ms
33,616 KB
testcase_12 AC 540 ms
33,616 KB
testcase_13 AC 342 ms
33,616 KB
testcase_14 AC 645 ms
33,616 KB
testcase_15 AC 561 ms
33,616 KB
testcase_16 AC 475 ms
33,616 KB
testcase_17 AC 796 ms
33,616 KB
testcase_18 AC 779 ms
33,616 KB
testcase_19 AC 664 ms
33,616 KB
testcase_20 AC 723 ms
33,616 KB
testcase_21 AC 678 ms
33,616 KB
testcase_22 AC 374 ms
33,616 KB
testcase_23 AC 474 ms
33,616 KB
testcase_24 AC 1,110 ms
33,616 KB
testcase_25 AC 566 ms
33,616 KB
testcase_26 AC 552 ms
33,616 KB
testcase_27 AC 1,138 ms
33,616 KB
testcase_28 AC 1,150 ms
33,616 KB
testcase_29 AC 1,161 ms
33,616 KB
testcase_30 AC 1,148 ms
33,616 KB
testcase_31 AC 1,148 ms
33,616 KB
testcase_32 AC 1,161 ms
33,616 KB
testcase_33 AC 214 ms
33,616 KB
testcase_34 AC 242 ms
33,616 KB
testcase_35 AC 229 ms
33,616 KB
testcase_36 AC 704 ms
33,616 KB
testcase_37 AC 332 ms
33,616 KB
testcase_38 AC 330 ms
33,616 KB
testcase_39 AC 326 ms
33,616 KB
testcase_40 AC 389 ms
33,616 KB
testcase_41 AC 439 ms
33,616 KB
testcase_42 AC 762 ms
33,616 KB
testcase_43 AC 1,036 ms
33,616 KB
testcase_44 AC 891 ms
33,616 KB
testcase_45 AC 291 ms
33,616 KB
testcase_46 AC 340 ms
33,616 KB
testcase_47 AC 327 ms
33,616 KB
testcase_48 AC 461 ms
33,616 KB
testcase_49 AC 222 ms
33,616 KB
testcase_50 AC 897 ms
33,616 KB
testcase_51 AC 282 ms
33,616 KB
testcase_52 AC 257 ms
33,616 KB
testcase_53 AC 311 ms
33,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
mod=10**9+7

FACT=[1]
for i in range(1,3*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(3*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0

j=max(0,N-K)

X=1
for i in range(K-N+1+j,K+1+j):
    X=X*i%mod

INV=pow(FACT[N],mod-2,mod)
ANS=X*Combi(N-1,j)*INV%mod

#print(X,j,ANS)

for i in range(j+1,N):
    X=X*(K+i)*pow((K+i-N),mod-2,mod)%mod

    ANS+=X*Combi(N-1,i)*INV%mod

print(ANS%mod)




0