10624 | 2024-04-06 23:30:45 | 111 | Tömbök előállítása | cpp17 | Runtime error 35/100 | 1.87s | 522468 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2048 KiB | ||||
3 | Accepted | 3ms | 2276 KiB | ||||
subtask2 | 10/10 | ||||||
4 | Accepted | 3ms | 2484 KiB | ||||
5 | Accepted | 3ms | 2580 KiB | ||||
6 | Accepted | 3ms | 2708 KiB | ||||
subtask3 | 10/10 | ||||||
7 | Accepted | 3ms | 2924 KiB | ||||
8 | Accepted | 4ms | 3344 KiB | ||||
9 | Accepted | 4ms | 3256 KiB | ||||
10 | Accepted | 3ms | 3288 KiB | ||||
11 | Accepted | 3ms | 3576 KiB | ||||
12 | Accepted | 14ms | 4620 KiB | ||||
13 | Accepted | 8ms | 4312 KiB | ||||
subtask4 | 7/7 | ||||||
14 | Accepted | 13ms | 4840 KiB | ||||
15 | Accepted | 17ms | 5200 KiB | ||||
16 | Accepted | 4ms | 4084 KiB | ||||
17 | Accepted | 3ms | 4104 KiB | ||||
18 | Accepted | 3ms | 4108 KiB | ||||
19 | Accepted | 4ms | 4392 KiB | ||||
20 | Accepted | 10ms | 5156 KiB | ||||
subtask5 | 8/8 | ||||||
21 | Accepted | 1.623s | 7512 KiB | ||||
22 | Accepted | 883ms | 6724 KiB | ||||
23 | Accepted | 1.194s | 7200 KiB | ||||
24 | Accepted | 569ms | 5784 KiB | ||||
25 | Accepted | 243ms | 5304 KiB | ||||
26 | Accepted | 57ms | 4648 KiB | ||||
27 | Accepted | 990ms | 6776 KiB | ||||
28 | Accepted | 305ms | 6012 KiB | ||||
29 | Accepted | 1.87s | 8472 KiB | ||||
30 | Accepted | 1.87s | 8404 KiB | ||||
subtask6 | 0/25 | ||||||
31 | Runtime error | 164ms | 522468 KiB | ||||
32 | Runtime error | 203ms | 522444 KiB | ||||
33 | Runtime error | 204ms | 522420 KiB | ||||
34 | Runtime error | 203ms | 522392 KiB | ||||
35 | Runtime error | 208ms | 522332 KiB | ||||
36 | Runtime error | 208ms | 522348 KiB | ||||
37 | Runtime error | 164ms | 522316 KiB | ||||
38 | Runtime error | 204ms | 522316 KiB | ||||
39 | Runtime error | 203ms | 522292 KiB | ||||
40 | Runtime error | 204ms | 522288 KiB | ||||
subtask7 | 0/40 | ||||||
41 | Runtime error | 204ms | 522260 KiB | ||||
42 | Runtime error | 164ms | 522260 KiB | ||||
43 | Runtime error | 165ms | 522032 KiB | ||||
44 | Runtime error | 164ms | 522036 KiB | ||||
45 | Runtime error | 208ms | 522024 KiB | ||||
46 | Runtime error | 209ms | 522016 KiB | ||||
47 | Runtime error | 159ms | 522032 KiB | ||||
48 | Runtime error | 204ms | 522012 KiB | ||||
49 | Runtime error | 207ms | 522040 KiB | ||||
50 | Runtime error | 208ms | 522016 KiB |