結果

問題 No.802 だいたい等差数列
ユーザー tpynerivertpyneriver
提出日時 2019-03-18 21:50:06
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,100 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 89,048 KB
最終ジャッジ日時 2023-09-26 10:27:45
合計ジャッジ時間 8,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,564 KB
testcase_01 AC 76 ms
75,616 KB
testcase_02 AC 76 ms
75,556 KB
testcase_03 AC 74 ms
71,228 KB
testcase_04 AC 77 ms
75,496 KB
testcase_05 AC 73 ms
71,024 KB
testcase_06 AC 77 ms
75,552 KB
testcase_07 AC 78 ms
75,560 KB
testcase_08 AC 77 ms
75,604 KB
testcase_09 AC 81 ms
75,528 KB
testcase_10 AC 93 ms
83,440 KB
testcase_11 AC 91 ms
85,708 KB
testcase_12 AC 82 ms
79,972 KB
testcase_13 AC 90 ms
85,320 KB
testcase_14 AC 218 ms
83,756 KB
testcase_15 AC 431 ms
80,984 KB
testcase_16 AC 130 ms
84,016 KB
testcase_17 AC 76 ms
76,040 KB
testcase_18 AC 76 ms
75,644 KB
testcase_19 AC 193 ms
82,232 KB
testcase_20 AC 1,089 ms
86,752 KB
testcase_21 AC 1,100 ms
88,836 KB
testcase_22 AC 96 ms
85,872 KB
testcase_23 AC 423 ms
80,296 KB
testcase_24 AC 76 ms
70,964 KB
testcase_25 AC 73 ms
70,924 KB
testcase_26 AC 81 ms
77,964 KB
testcase_27 AC 78 ms
77,608 KB
testcase_28 AC 412 ms
81,968 KB
testcase_29 AC 1,083 ms
89,048 KB
testcase_30 AC 71 ms
71,160 KB
testcase_31 AC 73 ms
70,892 KB
testcase_32 AC 72 ms
70,928 KB
testcase_33 AC 99 ms
79,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

D = D2 - D1
x = (M - 1) - D1*(N - 1)

fac = [1 for _ in range(N+x+1)]
for i in range(N+x):
    fac[i+1] = (i+1)*fac[i]%mod

print(sum([(-1)**j * fac[x+N-j*(D+1)] * pow(N*fac[x-j*(D+1)]*fac[j]*fac[N-j-1], mod - 2, mod)\
           for j in range(min(N, 1+x//(D+1)))])%mod)
0