10627 | 2024-04-07 00:08:28 | 111 | Tömbök előállítása | cpp17 | Accepted 100/100 | 1.442s | 4932 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
using vec=array<int,1000>;
int M;
vec operator*(vec a,vec b){
vec r{};
for(int i=0;i<M;i++){
for(int j=0;j<M;j++){
r[i]+=a[j]*b[(i-j+M)%M];
r[i]%=MOD;
}
}
return r;
}
vec vec_pow(vec x,int p){
vec r{};
r[0]=1;
while(p){
if(p&1){
r=r*x;
}
x=x*x;
p>>=1;
}
return r;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,L,R,K;
cin>>N>>M>>L>>R>>K;
vec v{};
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;
}
v=vec_pow(v,N);
cout<<v[K]<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2072 KiB | ||||
2 | Accepted | 3ms | 2376 KiB | ||||
3 | Accepted | 3ms | 2472 KiB | ||||
subtask2 | 10/10 | ||||||
4 | Accepted | 2ms | 2432 KiB | ||||
5 | Accepted | 3ms | 2824 KiB | ||||
6 | Accepted | 3ms | 3124 KiB | ||||
subtask3 | 10/10 | ||||||
7 | Accepted | 3ms | 3332 KiB | ||||
8 | Accepted | 3ms | 3548 KiB | ||||
9 | Accepted | 3ms | 3660 KiB | ||||
10 | Accepted | 3ms | 3940 KiB | ||||
11 | Accepted | 3ms | 3896 KiB | ||||
12 | Accepted | 3ms | 3912 KiB | ||||
13 | Accepted | 3ms | 3796 KiB | ||||
subtask4 | 7/7 | ||||||
14 | Accepted | 3ms | 3956 KiB | ||||
15 | Accepted | 3ms | 3912 KiB | ||||
16 | Accepted | 3ms | 3964 KiB | ||||
17 | Accepted | 3ms | 3960 KiB | ||||
18 | Accepted | 3ms | 3996 KiB | ||||
19 | Accepted | 3ms | 4248 KiB | ||||
20 | Accepted | 3ms | 4296 KiB | ||||
subtask5 | 8/8 | ||||||
21 | Accepted | 57ms | 4296 KiB | ||||
22 | Accepted | 28ms | 4300 KiB | ||||
23 | Accepted | 37ms | 4300 KiB | ||||
24 | Accepted | 25ms | 4264 KiB | ||||
25 | Accepted | 14ms | 4388 KiB | ||||
26 | Accepted | 8ms | 4348 KiB | ||||
27 | Accepted | 43ms | 4400 KiB | ||||
28 | Accepted | 12ms | 4400 KiB | ||||
29 | Accepted | 57ms | 4360 KiB | ||||
30 | Accepted | 57ms | 4352 KiB | ||||
subtask6 | 25/25 | ||||||
31 | Accepted | 14ms | 4356 KiB | ||||
32 | Accepted | 14ms | 4352 KiB | ||||
33 | Accepted | 6ms | 4504 KiB | ||||
34 | Accepted | 7ms | 4464 KiB | ||||
35 | Accepted | 4ms | 4460 KiB | ||||
36 | Accepted | 6ms | 4516 KiB | ||||
37 | Accepted | 3ms | 4364 KiB | ||||
38 | Accepted | 3ms | 4412 KiB | ||||
39 | Accepted | 9ms | 4304 KiB | ||||
40 | Accepted | 8ms | 4624 KiB | ||||
subtask7 | 40/40 | ||||||
41 | Accepted | 358ms | 4604 KiB | ||||
42 | Accepted | 1.151s | 4612 KiB | ||||
43 | Accepted | 1.31s | 4824 KiB | ||||
44 | Accepted | 1.442s | 4820 KiB | ||||
45 | Accepted | 1.287s | 4784 KiB | ||||
46 | Accepted | 342ms | 4776 KiB | ||||
47 | Accepted | 555ms | 4784 KiB | ||||
48 | Accepted | 10ms | 4932 KiB | ||||
49 | Accepted | 888ms | 4892 KiB | ||||
50 | Accepted | 418ms | 4884 KiB |