# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22139 | h0ngjun7 (#42) | 다항식 계산 (KRIII5P_2) | C++14 | 203 ms | 12832 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <vector>
using namespace std;
const int MAXN = 1000005;
typedef long long ll;
int N, P, a[MAXN];
ll s[MAXN];
int main() {
scanf("%d%d", &N, &P);
for (int i = N; i >= 0; i--) {
scanf("%d", &a[i]);
a[i] %= P;
s[i % (P - 1)] += a[i];
s[i % (P - 1)] %= P;
}
for (int i = 0; i < P; i++) {
ll g = 1, ans = 0;
for (int j = 0; j < P; j++) {
ans = (ans + g * s[j]) % P;
g = (g*i) % P;
}
printf("%lld\n", ans);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |