106242024-04-06 23:30:45111Tömbök előállításacpp17Runtime error 35/1001.87s522468 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define MOD 1000000007

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M,L,R,K;
	cin>>N>>M>>L>>R>>K;
	vector<int>v(M);
	for(int i=0;i<M;i++){
		int s=L%M>i?L/M:L/M-1;
		int e=R%M<i?R/M-1:R/M;
		v[i]=e-s;
	}
	int dp[N+1][M];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<M;j++){
			for(int k=0;k<M;k++){
				dp[i][j]+=dp[i-1][(j-k+M)%M]*v[k]%MOD;
			}
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[N][K]<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1832 KiB
2Accepted3ms2048 KiB
3Accepted3ms2276 KiB
subtask210/10
4Accepted3ms2484 KiB
5Accepted3ms2580 KiB
6Accepted3ms2708 KiB
subtask310/10
7Accepted3ms2924 KiB
8Accepted4ms3344 KiB
9Accepted4ms3256 KiB
10Accepted3ms3288 KiB
11Accepted3ms3576 KiB
12Accepted14ms4620 KiB
13Accepted8ms4312 KiB
subtask47/7
14Accepted13ms4840 KiB
15Accepted17ms5200 KiB
16Accepted4ms4084 KiB
17Accepted3ms4104 KiB
18Accepted3ms4108 KiB
19Accepted4ms4392 KiB
20Accepted10ms5156 KiB
subtask58/8
21Accepted1.623s7512 KiB
22Accepted883ms6724 KiB
23Accepted1.194s7200 KiB
24Accepted569ms5784 KiB
25Accepted243ms5304 KiB
26Accepted57ms4648 KiB
27Accepted990ms6776 KiB
28Accepted305ms6012 KiB
29Accepted1.87s8472 KiB
30Accepted1.87s8404 KiB
subtask60/25
31Runtime error164ms522468 KiB
32Runtime error203ms522444 KiB
33Runtime error204ms522420 KiB
34Runtime error203ms522392 KiB
35Runtime error208ms522332 KiB
36Runtime error208ms522348 KiB
37Runtime error164ms522316 KiB
38Runtime error204ms522316 KiB
39Runtime error203ms522292 KiB
40Runtime error204ms522288 KiB
subtask70/40
41Runtime error204ms522260 KiB
42Runtime error164ms522260 KiB
43Runtime error165ms522032 KiB
44Runtime error164ms522036 KiB
45Runtime error208ms522024 KiB
46Runtime error209ms522016 KiB
47Runtime error159ms522032 KiB
48Runtime error204ms522012 KiB
49Runtime error207ms522040 KiB
50Runtime error208ms522016 KiB