# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22925 | exqt | 다항식 계산 (KRIII5P_2) | C11 | 0 ms | 0 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 <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <utility>
#include <string>
#include <set>
#include <map>
using namespace std;
int main()
{
// freopen("in.txt", "r+", stdin);
// freopen("out.txt", "w+", stdout);
int n, p; cin >> n >> p;
vector<int> a(max(n+1, p+1), 0);
for(int i=n; i>=0; i--) a[0] = 0;
for(int i=n; i>=0; i--) cin >> a[i];
for(int i=n; i>=0; i--) a[i] %= p;
int c = a[0];
for(int i=p-1; i<=n; i++)
{
a[i%(p-1)] = (a[i%(p-1)] + a[i]) % p;
}
for(int i=0; i<p; i++)
{
if(i == 0)
{
cout << c << endl;
continue;
}
int r = 0;
int t = 1;
for(int j=0; j<p-1; j++)
{
r = (r + 1LL * t * a[j]) % p;
t = (t * i) % p;
}
cout << r << endl;
}
return 0;
}