Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


ll itr=0;
ll mod=1e9+7,a[3005];

ld M_PI=acos(-1.0);

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1)
		r=(r*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return r;
}



namespace FFT {//taken from https://www.codechef.com/viewsolution/11952970
    //taken from https://www.codechef.com/viewsolution/11939789
    const int N = 20;
    const int MAXN = (1<<N);
    class cmplx {
    private:
        double x, y;
    public:
        cmplx () : x(0.0), y(0.0) {}
        cmplx (double a) : x(a), y(0.0) {}
        cmplx (double a, double b) : x(a), y(b) {}
        double get_real() { return this->x; }
        double get_img() { return this->y; }
        cmplx conj() { return cmplx(this->x, -(this->y)); }
        cmplx operator = (const cmplx& a) { this->x = a.x; this->y = a.y; return *this; }
        cmplx operator + (const cmplx& b) { return cmplx(this->x + b.x, this->y + b.y); }
        cmplx operator - (const cmplx& b) { return cmplx(this->x - b.x, this->y - b.y); }
        cmplx operator * (const double& num) { return cmplx(this->x * num, this->y * num); }
        cmplx operator / (const double& num) { return cmplx(this->x / num, this->y / num); }
        cmplx operator * (const cmplx& b) { 
            return cmplx(this->x * b.x - this->y * b.y, this->y * b.x + this->x * b.y); 
        }
        cmplx operator / (const cmplx& b) {
            cmplx temp(b.x, -b.y); cmplx n = (*this) * temp;
            return n / (b.x * b.x + b.y * b.y);
        }
    };
    cmplx w[MAXN];
    cmplx f1[MAXN];
    int rev[MAXN];
    void ReserveBits(int k) {
        static int rk = -1, lim;
        if(k == rk) return ;
        rk = k, lim = 1 << k;
        for(int i = 1; i <= lim; ++i) {
            int j = rev[i-1], t = k - 1;
            while(t >= 0 && ((j>>t)&1)) {
                j ^= 1 << t; --t;
            }
            if(t >= 0) {
                j ^= 1 << t; --t;
            }
            rev[i] = j;
        }
    }
    void fft(cmplx *a, int k) {
        ReserveBits(k);
        int n = 1 << k;
        for(int i = 0 ; i < n; ++i) 
            if(rev[i] > i) swap(a[i], a[rev[i]]);
        for(int l = 2, m = 1; l <= n; l += l, m += m) {
            if(w[m].get_real() == 0 && w[m].get_img() == 0) {
                double angle = M_PI / m;
                cmplx ww(cos(angle), sin(angle));
                if(m > 1) {
                    for(int j = 0; j < m; ++j) {
                        if(j & 1) w[m + j] = w[(m+j)/2] * ww;
                        else w[m + j] = w[(m+j)/2];
                    }
                }
                else w[m] = cmplx(1, 0);
            }
            for(int i = 0; i < n; i += l) {
                for(int j = 0; j < m; ++j) {
                    cmplx v = a[i + j], u = a[i + j + m] * w[m + j];
                    a[i + j] = v + u;
                    a[i + j + m] = v - u;
                }
            }
        }
    }
    vector <long long> mul(vector<long long> a, vector<long long> b) {
        int k = 1;
        while((1<<k) < (a.size() + b.size())) ++k;
        int n = (1<<k);
        for(int i = 0; i < n; ++i) f1[i] = cmplx(0,0);
        for(int i = 0; i < a.size(); ++i) f1[i] = f1[i] + cmplx(a[i], 0);
        for(int i = 0; i < b.size(); ++i) f1[i] = f1[i] + cmplx(0, b[i]);
        fft(f1, k);
        for(int i = 0; i <= n/2; ++i) {
            cmplx p = f1[i] + f1[(n-i)%n].conj();
            cmplx _q = f1[(n-i)%n] - f1[i].conj();
            cmplx q(_q.get_img(), _q.get_real());
            f1[i] = (p * q) * 0.25;
            if(i > 0) f1[(n - i)] = f1[i].conj();
        }
        for(int i = 0; i < n; ++i) f1[i] = f1[i].conj();
        fft(f1, k);
        vector<long long> ans(a.size() + b.size() - 1);
        for(int i = 0; i < ans.size(); ++i) {
            ans[i] = (long long) (f1[i].get_real() / n + 0.5) % mod;
        }
        return ans;
    }
};

ll ans[3005];
vector<vll> global_v;

vll solve(int lo,int hi)
{
	if(lo==hi)return global_v[lo];
	int mid=(lo+hi)/2;
	vll v1=solve(lo,mid);
	vll v2=solve(mid+1,hi);
	return FFT::mul(v1,v2);
}

int main()
{ios_base::sync_with_stdio(false);
cin>>mod;
rep(i,0,mod-1)
{
	cin>>a[i];
}

rep(i,0,mod-1)
{
	if(a[i]==0)continue;
	ll r=1;
	global_v.clear();
	rep(j,0,mod-1)
	{
		if(i==j)continue;
		r=(r*(i-j))%mod;
		vll v;
		v.pb((mod-j)%mod);
		v.pb(1);
		global_v.pb(v);
	}
	int sz=global_v.size();
	vll an=solve(0,sz-1);
	sz=an.size();
	rep(i,0,sz-1)
	{
		ans[i]=(ans[i]+r*an[i])%mod;
	}
}

rep(i,0,mod-1)
{
	ol((ans[i]+mod)%mod);os;
}
return 0;
}



Compiler output:
In file included from /usr/include/c++/14/cmath:47,
                 from a.cc:18:
a.cc:58:4: error: expected unqualified-id before numeric constant
   58 | ld M_PI=acos(-1.0);
      |    ^~~~