#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1005];
int n, p, a0;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> p;
for(int i = n, x; i >= 0; i--){
cin >> x;
a[i % (p-1)] += x;
if(!i) a0 = x;
}
for(int i = p; i--;) a[i] %= p;
for(int j = 0; j < p; j++){
if(!j){
printf("%d\n",a0%p);
continue;
}
int k = 1;
int ans = 0;
for(int i = 0; i < p; i++){
ans = (ans + k * a[i]) % p;
k = k * j % p;
}
printf("%d\n",ans);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
612 KB |
Output is correct |
5 |
Correct |
2 ms |
612 KB |
Output is correct |
6 |
Correct |
23 ms |
612 KB |
Output is correct |
7 |
Correct |
21 ms |
612 KB |
Output is correct |
8 |
Correct |
21 ms |
612 KB |
Output is correct |
9 |
Correct |
23 ms |
612 KB |
Output is correct |
10 |
Correct |
21 ms |
612 KB |
Output is correct |
11 |
Correct |
13 ms |
612 KB |
Output is correct |
12 |
Correct |
17 ms |
612 KB |
Output is correct |
13 |
Correct |
7 ms |
612 KB |
Output is correct |
14 |
Correct |
4 ms |
612 KB |
Output is correct |
15 |
Correct |
5 ms |
612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
612 KB |
Output is correct |
5 |
Correct |
2 ms |
612 KB |
Output is correct |
6 |
Correct |
23 ms |
612 KB |
Output is correct |
7 |
Correct |
21 ms |
612 KB |
Output is correct |
8 |
Correct |
21 ms |
612 KB |
Output is correct |
9 |
Correct |
23 ms |
612 KB |
Output is correct |
10 |
Correct |
21 ms |
612 KB |
Output is correct |
11 |
Correct |
13 ms |
612 KB |
Output is correct |
12 |
Correct |
17 ms |
612 KB |
Output is correct |
13 |
Correct |
7 ms |
612 KB |
Output is correct |
14 |
Correct |
4 ms |
612 KB |
Output is correct |
15 |
Correct |
5 ms |
612 KB |
Output is correct |
16 |
Correct |
143 ms |
612 KB |
Output is correct |
17 |
Correct |
133 ms |
612 KB |
Output is correct |
18 |
Correct |
139 ms |
10380 KB |
Output is correct |
19 |
Correct |
146 ms |
19944 KB |
Output is correct |
20 |
Correct |
165 ms |
29612 KB |
Output is correct |
21 |
Correct |
181 ms |
39296 KB |
Output is correct |
22 |
Correct |
168 ms |
48968 KB |
Output is correct |
23 |
Correct |
182 ms |
58772 KB |
Output is correct |
24 |
Correct |
152 ms |
68452 KB |
Output is correct |
25 |
Correct |
153 ms |
78032 KB |
Output is correct |
26 |
Correct |
147 ms |
87740 KB |
Output is correct |
27 |
Correct |
156 ms |
97412 KB |
Output is correct |
28 |
Correct |
147 ms |
107092 KB |
Output is correct |
29 |
Correct |
160 ms |
116768 KB |
Output is correct |
30 |
Correct |
157 ms |
126456 KB |
Output is correct |