結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー huhihusenonu mutuhuhihusenonu mutu
提出日時 2020-08-22 13:42:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 163,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 08:07:58
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
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 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define P pair<ll,ll>
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
#define pi 3.14159265359
using namespace std;
ll k[300000];
int mypow(ll a,ll b,ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	ll fa = mypow(a, b / 2, c);
	return fa * fa%c;
}
int nCr(int a, int b) {
	return k[a] * mypow(k[b], Mod - 2, Mod) % Mod * mypow(k[a - b], Mod - 2, Mod) % Mod;
}
int main() {
	ll a, b, c, d, ans = 0;
	cin >> a >> b >> c >> d;
	ll z = d - (a - 1)*(c - 1), x = b - d;
	k[0] = 1;
	f(i, max(a,z)) {
		k[i + 1] = k[i] * (i + 1);
	}
	for (; z >= a - 1; z--) {
		ans += nCr(z-1, a - 2)*x%Mod;
		ans %= Mod;
		x++;
	}
	cout << ans * k[a] % Mod << endl;
	ggr;
}
0