結果

問題 No.1127 変形パスカルの三角形
ユーザー titiatitia
提出日時 2023-10-23 02:32:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 1,500 ms
コード長 543 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 118,204 KB
最終ジャッジ日時 2023-10-23 02:32:45
合計ジャッジ時間 5,730 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
102,188 KB
testcase_01 AC 119 ms
115,828 KB
testcase_02 AC 108 ms
117,940 KB
testcase_03 AC 104 ms
117,412 KB
testcase_04 AC 86 ms
111,420 KB
testcase_05 AC 101 ms
117,148 KB
testcase_06 AC 115 ms
115,828 KB
testcase_07 AC 97 ms
116,620 KB
testcase_08 AC 96 ms
116,620 KB
testcase_09 AC 110 ms
115,828 KB
testcase_10 AC 135 ms
115,828 KB
testcase_11 AC 110 ms
117,940 KB
testcase_12 AC 109 ms
117,940 KB
testcase_13 AC 107 ms
117,676 KB
testcase_14 AC 103 ms
117,412 KB
testcase_15 AC 95 ms
116,620 KB
testcase_16 AC 104 ms
117,412 KB
testcase_17 AC 97 ms
116,620 KB
testcase_18 AC 105 ms
117,676 KB
testcase_19 AC 110 ms
117,940 KB
testcase_20 AC 137 ms
118,204 KB
testcase_21 AC 111 ms
118,204 KB
testcase_22 AC 97 ms
116,620 KB
testcase_23 AC 110 ms
115,828 KB
testcase_24 AC 103 ms
117,412 KB
testcase_25 AC 105 ms
117,412 KB
testcase_26 AC 105 ms
117,676 KB
testcase_27 AC 109 ms
117,940 KB
testcase_28 AC 109 ms
117,940 KB
testcase_29 AC 95 ms
116,620 KB
testcase_30 AC 92 ms
113,612 KB
testcase_31 AC 110 ms
118,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b=map(int,input().split())
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

print((Combi(n-1,k-1)*a+Combi(n-1,k-2)*b)%mod)

ANS=0
for k in range(1,n+2):
    ANS+=((Combi(n-1,k-1)*a+Combi(n-1,k-2)*b)%mod)**2
    ANS%=mod

print(ANS)

0