結果

問題 No.802 だいたい等差数列
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-03-30 15:39:29
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 3,059 ms
コンパイル使用メモリ 159,800 KB
実行使用メモリ 261,088 KB
最終ジャッジ日時 2024-03-30 15:39:49
合計ジャッジ時間 16,873 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
6,676 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1 ms
6,676 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using namespace std;
using mint = modint1000000007;
using ll = long long;
const int MAX = 11000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(long long n, long long k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
	ll N, M, D1, D2;cin >> N >> M >> D1 >> D2;
	ll D = D2 - D1;
	ll x =M - (D1 * (N -1)) - 1;
	if (x < 0) {
		cout << 0 << endl;return 0;
	}
	COMinit();
	mint ans = 0;
	for (ll p = 0;p < N;p++) {
		mint tmp = mint(COM(x + N - (p * (D + 1)), N)) * mint(COM(N - 1, p));
	}
	
	cout << ans.val() << endl;
}
0