結果

問題 No.802 だいたい等差数列
ユーザー yurujirouyurujirou
提出日時 2021-09-26 16:10:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,561 bytes
コンパイル時間 3,380 ms
コンパイル使用メモリ 172,896 KB
実行使用メモリ 19,316 KB
最終ジャッジ日時 2023-09-19 02:54:33
合計ジャッジ時間 16,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
19,028 KB
testcase_01 AC 225 ms
19,056 KB
testcase_02 AC 225 ms
19,024 KB
testcase_03 AC 225 ms
19,044 KB
testcase_04 AC 227 ms
19,064 KB
testcase_05 AC 225 ms
19,124 KB
testcase_06 AC 226 ms
19,316 KB
testcase_07 AC 224 ms
19,044 KB
testcase_08 AC 225 ms
19,044 KB
testcase_09 AC 225 ms
19,044 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 228 ms
19,040 KB
testcase_13 RE -
testcase_14 AC 230 ms
19,024 KB
testcase_15 AC 227 ms
19,064 KB
testcase_16 AC 228 ms
19,004 KB
testcase_17 AC 228 ms
19,128 KB
testcase_18 AC 227 ms
19,072 KB
testcase_19 AC 229 ms
19,060 KB
testcase_20 AC 230 ms
19,056 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 229 ms
19,076 KB
testcase_24 AC 228 ms
19,048 KB
testcase_25 AC 225 ms
19,012 KB
testcase_26 AC 228 ms
19,060 KB
testcase_27 AC 228 ms
19,060 KB
testcase_28 AC 228 ms
19,048 KB
testcase_29 RE -
testcase_30 AC 228 ms
19,016 KB
testcase_31 AC 227 ms
19,016 KB
testcase_32 AC 226 ms
19,044 KB
testcase_33 AC 224 ms
19,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <functional>
#include <math.h>
#include <complex>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define RREP(i,n) for(int i = (int)n-1; i >= 0; i--)
#define LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define LP pair<long long ,long long>
#define P pair<int, int>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE	1000010
#define MOD 1000000007
typedef long long LL;

LL F[SIZE], FI[SIZE];
void init() {
	F[0] = FI[0] = 1;
	for (LL i = 1; i < SIZE; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		FI[i] = (FI[i - 1] * inv_mod(i, MOD)) % MOD;
	}
}

LL comb(LL n, LL k) {
	if (n < k) return 0;
	LL res = F[n];
	res = (res * FI[n - k]) % MOD;
	res = (res * FI[k]) % MOD;
	return res;
}

LL N, M, D1, D2;

LL cal(LL x) {
	LL n = (M - 1) - (N - 1) * D1;
	n -= x * (D2 - D1 + 1);
	LL res = comb(n + N, N);
	res = (res * comb(N - 1, x)) % MOD;
	return res;
}

int main() {
	cin >> N >> M >> D1 >> D2;
	init();

	LL ans = 0;
	for (LL x = 1; x <= N - 1; x++) {
		LL res = cal(x);
		if (x % 2 == 1) {
			ans = (ans + res) % MOD;
		}
		else {
			ans = (ans - res) % MOD;
		}
	}
	ans = (cal(0) - ans) % MOD;
	cout << (ans + MOD) % MOD << endl;
}
0