結果

問題 No.1127 変形パスカルの三角形
ユーザー tyawanmusityawanmusi
提出日時 2020-07-28 11:39:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 722 ms / 1,500 ms
コード長 384 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 90,724 KB
最終ジャッジ日時 2023-09-11 06:26:17
合計ジャッジ時間 15,927 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,428 KB
testcase_01 AC 722 ms
90,724 KB
testcase_02 AC 536 ms
88,548 KB
testcase_03 AC 423 ms
84,864 KB
testcase_04 AC 179 ms
78,380 KB
testcase_05 AC 395 ms
84,828 KB
testcase_06 AC 721 ms
90,452 KB
testcase_07 AC 286 ms
80,904 KB
testcase_08 AC 277 ms
80,664 KB
testcase_09 AC 610 ms
87,772 KB
testcase_10 AC 624 ms
87,892 KB
testcase_11 AC 541 ms
88,708 KB
testcase_12 AC 507 ms
87,140 KB
testcase_13 AC 481 ms
87,060 KB
testcase_14 AC 407 ms
84,692 KB
testcase_15 AC 260 ms
80,532 KB
testcase_16 AC 444 ms
85,928 KB
testcase_17 AC 273 ms
80,772 KB
testcase_18 AC 468 ms
85,972 KB
testcase_19 AC 547 ms
88,660 KB
testcase_20 AC 559 ms
88,664 KB
testcase_21 AC 567 ms
88,904 KB
testcase_22 AC 266 ms
80,472 KB
testcase_23 AC 618 ms
87,764 KB
testcase_24 AC 421 ms
84,888 KB
testcase_25 AC 442 ms
86,044 KB
testcase_26 AC 479 ms
86,928 KB
testcase_27 AC 543 ms
88,452 KB
testcase_28 AC 530 ms
88,640 KB
testcase_29 AC 252 ms
80,508 KB
testcase_30 AC 208 ms
79,352 KB
testcase_31 AC 565 ms
88,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b=map(int,input().split())
n,k=map(int,input().split())
f=[1]
mod=10**9+7
for i in range(n+17):f.append(f[-1]*(i+1)%mod)
def comb(n,r):
  return f[n]*pow(f[n-r],mod-2,mod)*pow(f[r],mod-2,mod)%mod
def ff(n,k):
  ans=0
  if k!=n:
    ans+=a*comb(n-1,k)
  if k!=0:
    ans+=b*comb(n-1,k-1)
  return ans%mod
print(ff(n,k-1))
ans=0
for k in range(n+1):ans=(ans+ff(n,k)**2)%mod
print(ans)
0