結果

問題 No.1127 変形パスカルの三角形
ユーザー eSeFeSeF
提出日時 2020-07-26 12:08:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 1,500 ms
コード長 290 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 79,092 KB
最終ジャッジ日時 2023-09-10 20:39:01
合計ジャッジ時間 4,433 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,380 KB
testcase_01 AC 83 ms
79,092 KB
testcase_02 AC 83 ms
77,928 KB
testcase_03 AC 80 ms
77,636 KB
testcase_04 AC 78 ms
76,040 KB
testcase_05 AC 79 ms
77,152 KB
testcase_06 AC 82 ms
78,876 KB
testcase_07 AC 79 ms
76,672 KB
testcase_08 AC 78 ms
76,608 KB
testcase_09 AC 81 ms
78,456 KB
testcase_10 AC 82 ms
78,624 KB
testcase_11 AC 83 ms
78,188 KB
testcase_12 AC 83 ms
77,824 KB
testcase_13 AC 82 ms
77,740 KB
testcase_14 AC 81 ms
77,312 KB
testcase_15 AC 79 ms
76,452 KB
testcase_16 AC 80 ms
77,588 KB
testcase_17 AC 79 ms
76,680 KB
testcase_18 AC 82 ms
77,788 KB
testcase_19 AC 81 ms
78,020 KB
testcase_20 AC 82 ms
78,248 KB
testcase_21 AC 82 ms
78,008 KB
testcase_22 AC 79 ms
76,584 KB
testcase_23 AC 83 ms
78,284 KB
testcase_24 AC 80 ms
77,444 KB
testcase_25 AC 81 ms
77,628 KB
testcase_26 AC 80 ms
77,572 KB
testcase_27 AC 82 ms
78,084 KB
testcase_28 AC 80 ms
77,932 KB
testcase_29 AC 78 ms
76,496 KB
testcase_30 AC 79 ms
76,552 KB
testcase_31 AC 83 ms
78,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b=map(int,input().split())
n,k=map(int,input().split())
m=int(1e9)+7
f=[1]*(2*n+1)
for i in range(2*n):
    f[i+1]=(f[i]*(i+1))%m
def c(i,j):
    return f[i]*(pow(f[j]*f[i-j],m-2,m))
def d(i,j):
    return (c(i-1,j-1)*a+c(i-1,j-2)*b)%m
print(d(n,k))
print((a*d(2*n-1,n)+b*d(2*n-1,n+1))%m)
0