91582024-02-16 16:27:41111Séta Alatti Területcpp17Runtime error 37/100361ms522456 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define MOD 1000000007

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N, M, P, R;
	cin >> N >> M >> P >> R;
	int dp[N + 1][M + 1][P];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= N; i++) {
		dp[i][0][0] = 1;
	}
	for (int i = 0; i <= M; i++) {
		dp[0][i][0] = 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			for (int k = 0; k < P; k++) {
				dp[i][j][k] = (dp[i][j - 1][k] + dp[i - 1][j][(k + j * (P - 1)) % P]) % MOD;
			}
		}
	}
	cout << dp[N][M][R] << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2020 KiB
2Accepted3ms2176 KiB
subtask216/16
3Accepted3ms2540 KiB
4Accepted3ms2828 KiB
5Accepted3ms2780 KiB
6Accepted3ms3024 KiB
7Accepted3ms3028 KiB
8Accepted3ms3116 KiB
9Accepted3ms3128 KiB
10Accepted3ms3352 KiB
11Accepted3ms3468 KiB
12Accepted3ms3472 KiB
13Accepted3ms3500 KiB
subtask321/21
14Accepted3ms3684 KiB
15Accepted3ms3760 KiB
16Accepted6ms6068 KiB
17Accepted6ms6432 KiB
18Accepted17ms15296 KiB
19Accepted17ms14724 KiB
20Accepted8ms8968 KiB
21Accepted4ms5640 KiB
22Accepted7ms7684 KiB
subtask40/25
23Runtime error167ms522456 KiB
24Runtime error165ms522428 KiB
25Runtime error207ms522396 KiB
26Runtime error163ms522400 KiB
27Runtime error162ms522252 KiB
28Runtime error163ms522016 KiB
subtask50/38
29Accepted361ms348960 KiB
30Accepted92ms98796 KiB
31Runtime error165ms522012 KiB
32Runtime error163ms521992 KiB
33Runtime error162ms521756 KiB
34Runtime error165ms521744 KiB
35Runtime error164ms521724 KiB
36Runtime error163ms521740 KiB
37Runtime error158ms521740 KiB