結果

問題 No.1127 変形パスカルの三角形
ユーザー 👑 KazunKazun
提出日時 2021-01-29 18:00:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 709 ms / 1,500 ms
コード長 561 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 86,068 KB
実行使用メモリ 80,896 KB
最終ジャッジ日時 2023-09-09 11:43:39
合計ジャッジ時間 15,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,852 KB
testcase_01 AC 709 ms
79,480 KB
testcase_02 AC 489 ms
80,420 KB
testcase_03 AC 382 ms
79,396 KB
testcase_04 AC 156 ms
77,112 KB
testcase_05 AC 357 ms
79,044 KB
testcase_06 AC 662 ms
79,564 KB
testcase_07 AC 256 ms
78,124 KB
testcase_08 AC 250 ms
77,956 KB
testcase_09 AC 556 ms
78,860 KB
testcase_10 AC 567 ms
79,036 KB
testcase_11 AC 500 ms
80,472 KB
testcase_12 AC 460 ms
80,012 KB
testcase_13 AC 437 ms
79,728 KB
testcase_14 AC 370 ms
79,080 KB
testcase_15 AC 232 ms
78,328 KB
testcase_16 AC 405 ms
79,264 KB
testcase_17 AC 242 ms
77,904 KB
testcase_18 AC 426 ms
79,760 KB
testcase_19 AC 494 ms
80,624 KB
testcase_20 AC 511 ms
80,692 KB
testcase_21 AC 521 ms
80,896 KB
testcase_22 AC 237 ms
77,560 KB
testcase_23 AC 569 ms
78,960 KB
testcase_24 AC 387 ms
79,352 KB
testcase_25 AC 409 ms
79,580 KB
testcase_26 AC 439 ms
80,164 KB
testcase_27 AC 499 ms
80,316 KB
testcase_28 AC 485 ms
80,320 KB
testcase_29 AC 228 ms
77,856 KB
testcase_30 AC 182 ms
77,344 KB
testcase_31 AC 516 ms
80,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#================================================
def nCr(n,r):
    if 0<=r<=n:
        return (F[n]*G[r]*G[n-r])%Mod
    else:
        return 0
#================================================
Mod=10**9+7
a,b=map(int,input().split())
N,K=map(int,input().split())

F=[1]*(N+1)
for i in range(2,N+1):
    F[i]=(F[i-1]*i)%Mod

G=[1]*(N+1)
G[-1]=pow(F[-1],Mod-2,Mod)
for i in range(N-1,-1,-1):
    G[i]=(G[i+1]*(i+1))%Mod

X=0
for k in range(1,N+2):
    X+=pow(a*nCr(N-1,k-1)+b*nCr(N-1,k-2),2,Mod)
    X%=Mod

print((a*nCr(N-1,K-1)+b*nCr(N-1,K-2))%Mod,X,sep="\n")
0