結果

問題 No.802 だいたい等差数列
ユーザー convexineqconvexineq
提出日時 2021-03-25 04:43:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 923 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 99,500 KB
最終ジャッジ日時 2023-08-17 22:55:43
合計ジャッジ時間 6,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
87,484 KB
testcase_01 AC 95 ms
87,520 KB
testcase_02 AC 94 ms
87,736 KB
testcase_03 AC 96 ms
87,800 KB
testcase_04 AC 94 ms
87,524 KB
testcase_05 AC 89 ms
87,484 KB
testcase_06 AC 95 ms
87,824 KB
testcase_07 AC 93 ms
87,660 KB
testcase_08 AC 91 ms
87,576 KB
testcase_09 AC 93 ms
87,888 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 105 ms
90,596 KB
testcase_16 RE -
testcase_17 AC 88 ms
87,344 KB
testcase_18 AC 88 ms
87,720 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 99 ms
88,640 KB
testcase_24 AC 87 ms
87,596 KB
testcase_25 AC 89 ms
87,580 KB
testcase_26 AC 89 ms
87,664 KB
testcase_27 AC 89 ms
87,580 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 90 ms
87,628 KB
testcase_31 AC 89 ms
87,352 KB
testcase_32 AC 89 ms
87,428 KB
testcase_33 AC 101 ms
91,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

SIZE=5*10**5+1; MOD=10**9+7 #998244353 #ここを変更する

inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

def chofuku(box,ball): # nHk mod MOD の計算
    if box == ball == 0: return 1
    return choose(box+ball-1,ball)

n,m,d1,d2 = map(int,input().split())
n -= 1
m -= d1*n+1
d = d2-d1+1
dp = [0]*(m+1)
r = 1
for i in range(n+1):
    if d*i > m: break
    dp[d*i] = choose(n,i)*r
    r *= -1
ans = 0
for i,ai in enumerate(dp):
    ans += chofuku(n+2,m-i)*ai%MOD
print(ans%MOD)
0