Language: C++

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 924844033;
using ll = long long;
using u32 = uint32_t;
using namespace std;
#pragma GCC optimize ("O2")

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};


#include <cmath>
namespace FFT {
    const int max_base = 19, maxN = 1 << max_base; // N <= 2e5
    const double PI = acos(-1);
    struct num {
        double x{}, y{};
        num() = default;
        num(double x, double y): x(x), y(y) {}
        explicit num(double r): x(cos(r)), y(sin(r)) {}
    };
    using ar = array<num, maxN>;
    using arr = array<ll, maxN>;
    num operator+(num a, num b) { return {a.x + b.x, a.y + b.y}; }
    num operator-(num a, num b) { return {a.x - b.x, a.y - b.y}; }
    num operator*(num a, num b) { return {a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x}; }
    num conj(num a) {return {a.x, -a.y}; }
    ar root;
    arr rev;
    bool is_root_prepared = false;

    void prepare_root(){
        if(is_root_prepared) return;
        is_root_prepared = true;
        root[1] = num(1, 0);
        for (int i = 1; i < max_base; ++i) {
            num x(2*PI / (1LL << (i+1)));
            for (ll j = (1LL << (i-1)); j < (1LL << (i)); ++j) {
                root[2*j] = root[j];
                root[2*j+1] = root[j]*x;
            }
        }
    }

    int base, N;
    int lastN = -1;

    void prepare_rev(){
        if(lastN == N) return;
        lastN = N;
        for (int i = 0; i < N; ++i) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (base - 1));
    }

    void fft(ar &a, ar &f){
        for (int i = 0; i < N; ++i) f[i] = a[rev[i]];
        for (int k = 1; k < N; k <<= 1) {
            for (int i = 0; i < N; i += 2*k) {
                for (int j = 0; j < k; ++j) {
                    num z = f[i+j+k]* root[j+k];
                    f[i+j+k] = f[i+j] - z;
                    f[i+j] = f[i+j] + z;
                }
            }
        }
    }
    ar a, b, f, g;
    arr A, B, C;

    void multi_mod(int m){
        for (int i = 0; i < N; ++i) {
            ll x = A[i] % m;
            a[i] = num(x & ((1LL << 15)-1), x >> 15);
        }
        for (int i = 0; i < N; ++i) {
            ll x = B[i] % m;
            b[i] = num(x & ((1LL << 15)-1), x >> 15);
        }
        fft(a, f);
        fft(b, g);
        for (int i = 0; i < N; ++i) {
            int j = (N-i) &(N-1);
            num a1 = (f[i] + conj(f[j])) * num(0.5, 0);
            num a2 = (f[i] - conj(f[j])) * num(0, -0.5);
            num b1 = (g[i] + conj(g[j])) * num(0.5/N, 0);
            num b2 = (g[i] - conj(g[j])) * num(0, -0.5/N);
            a[j] = a1*b1 + a2*b2 * num(0, 1);
            b[j] = a1*b2 + a2*b1;
        }
        fft(a, f);
        fft(b, g);
        for (int i = 0; i < N; ++i) {
            ll aa = f[i].x + 0.5;
            ll bb = g[i].x + 0.5;
            ll cc = f[i].y + 0.5;
            C[i] = (aa + bb % m * (1LL << 15) + cc% m *(1LL << 30)) % m;
        }
    }

    void prepare_AB(int n1, int n2){
        base = 1;
        N = 2;
        while(N < n1+n2) base++, N <<= 1;
        for (int i = n1; i < N; ++i) A[i] = 0;
        for (int i = n2; i < N; ++i) B[i] = 0;
        prepare_root();
        prepare_rev();
    }

    void multi_mod(int n1, int n2, int m){
        prepare_AB(n1, n2);
        multi_mod(m);
    }
}

struct poly {
    vector<int> v;
    poly() = default;
    explicit poly(vector<int> vv) : v(std::move(vv)) {};
    int size() {return (int)v.size(); }
    poly cut(int len){
        if(len < v.size()) v.resize(static_cast<unsigned long>(len));
        return *this;
    }
    inline int& operator[] (int i) {return v[i]; }
};

poly operator+(poly &A, poly &B){
    poly C;
    C.v = vector<int>(max(A.size(), B.size()));
    for (int i = 0; i < A.size(); ++i) C[i] = A[i];
    for (int i = 0; i < B.size(); ++i) (C[i] += B[i]) %= MOD;
    return C;
}

poly operator-(poly &A, poly &B){
    poly C;
    C.v = vector<int>(max(A.size(), B.size()));
    for (int i = 0; i < A.size(); ++i) C[i] = A[i];
    for (int i = 0; i < B.size(); ++i) (C[i] += MOD-B[i]) %= MOD;
    return C;
}

poly operator* (poly &A, poly &B){
    poly C;
    C.v = vector<int>(A.size() + B.size()-1);
    for (int i = 0; i < A.size(); ++i) FFT::A[i] = A[i];
    for (int i = 0; i < B.size(); ++i) FFT::B[i] = B[i];
    FFT::multi_mod(A.size(), B.size(), MOD);
    for (int i = 0; i < C.size(); ++i) C[i] = FFT::C[i];
    return C;
}


int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        G[a-1].emplace_back(b-1);
        G[b-1].emplace_back(a-1);
    }
    deque<int> Q;
    vector<int> num(n);
    {
        stack<int> s;
        int cnt = 0;
        vector<int> visited(n, 0);
        s.emplace(0);
        while(!s.empty()){
            int a = s.top(); s.pop();
            visited[a]++;
            num[a] = cnt++;
            Q.emplace_front(a);
            for (auto &&i : G[a]) {
                if(!visited[i]) s.emplace(i);
            }
        }
    }
    vector<int> v(n, 1);
    vector<int> u(n+1);
    while(!Q.empty()){
        int i = Q.front(); Q.pop_front();
        for (auto &&j : G[i]) {
            if(num[i] < num[j]) v[i] += v[j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (auto &&j : G[i]) {
            if(i < j){
                int p = min(v[i], v[j]);
                u[p]++; u[n-p]++;
            }
        }
    }
    Factorial<ll> fact(n, MOD);
    for (int i = 0; i <= n; ++i) {
        u[i] = static_cast<int>((fact[i] * u[i]) % MOD);
    }
    vector<int> uu(n+1);
    for (int i = 0; i <= n; ++i) {
        uu[i] = static_cast<int>(fact[i-n]);
    }
    poly f(u), g(uu);
    poly h = f*g;
    for (int k = 1; k <= n; ++k) {
        ll ans = (fact.C(n, k)*n%MOD + (MOD - fact[-k]*h[n+k]%MOD)) % MOD;
        printf("%lld\n", ans);
    }
    return 0;
}


Compiler output:
a.cc:13:13: error: 'uint32_t' does not name a type
   13 | using u32 = uint32_t;
      |             ^~~~~~~~
a.cc:10:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    9 | #include <bitset>
  +++ |+#include <cstdint>
   10 | 
a.cc:17:39: error: '::numeric_limits' has not been declared
   17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
      |                                       ^~~~~~~~~~~~~~
a.cc:17:55: error: expected primary-expression before '>' token
   17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
      |                                                       ^
a.cc:17:61: error: no matching function for call to 'max()'
   17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
      |                                                        ~~~~~^~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 0 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 0 provided
a.cc: In function 'T pow_(T, T, T)':
a.cc:21:5: error: 'uint64_t' was not declared in this scope
   21 |     uint64_t u = 1, xx = x;
      |     ^~~~~~~~
a.cc:21:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:23:18: error: 'u' was not declared in this scope
   23 |         if (n&1) u = u * xx % M;
      |                  ^
a.cc:23:26: error: 'xx' was not declared in this scope; did you mean 'x'?
   23 |         if (n&1) u = u * xx % M;
      |                          ^~
      |                          x
a.cc:24:9: error: 'xx' was not declared in this scope; did you mean 'x'?
   24 |         xx = xx * xx % M;
      |         ^~
      |         x
a.cc:27:27: error: 'u' was not declared in this scope
   27 |     return static_cast<T>(u);
      |                           ^
a.cc: At global scope:
a.cc:32:12: error: 'uint64_t' was not declared in this scope
   32 |     vector<uint64_t> facts, factinv;
      |            ^~~~~~~~
a.cc:32:12: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:32:20: error: template argument 1 is invalid
   32 |     vector<uint64_t> facts, factinv;
      |                    ^
a.cc:32:20: error: template argument 2 is invalid
a.cc: In constructor 'Factorial<T>::Factorial(int, T)':
a.cc:35:49: error: 'u32' does not name a type
   35 |     Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
      |                                                 ^~~
a.cc:35:81: error: 'u32' does not name a type
   35 |     Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
      |                                                                                 ^~~
a.cc:36:14: error: invalid types 'int[int]' for array subscript
   36 |         facts[0] = 1;
      |              ^
a.cc:37:44: error: invalid types 'int[int]' for array subscript
   37 |         for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
      |                                            ^
a.cc:37:55: error: invalid types 'int[int]' for array subscript
   37 |         for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
      |                                                       ^
a.cc:38:16: error: invalid types 'int[int]' for array subscript
   38 |         factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
      |                ^
a.cc:38:32: error: invalid types 'int[int]' for array subscript
   38 |         factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
      |                                ^
a.cc:38:49: error: 'uint64_t' does not name a type
   38 |         factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
      |                                                 ^~~~~~~~
a.cc:38:49: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:38:81: error: 'uint64_t' does not name a type
   38 |         factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
      |                                                                                 ^~~~~~~~
a.cc:38:81: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:39:47: error: invalid types 'int[int]' for array subscript
   39 |         for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
      |                                               ^
a.cc:39:60: error: invalid types 'int[int]' for array subscript
   39 |         for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
      |                                                            ^
a.cc: In member function 'T Factorial<T>::fact(int) const':
a.cc:43:47: error: invalid types 'const int[int]' for array subscript
   43 |         if(k >= 0) return static_cast<T>(facts[k]);
      |                                               ^
a.cc:44:43: error: invalid types 'const int[int]' for array subscript
   44 |         else return static_cast<T>(factinv[-k]);
      |                                           ^
a.cc: In member function 'T Factorial<T>::operator[](const int&) const':
a.cc:48:47: error: invalid types 'const int[const int]' for array subscript
   48 |         if(k >= 0) return static_cast<T>(facts[k]);
      |                                               ^
a.cc:49:43: error: invalid types 'const int[int]' for array subscript
   49 |         else return static_cast<T>(factinv[-k]);
      |                                           ^
a.cc: In member function 'T Factorial<T>::C(int, int) const':
a.cc:54:36: error: invalid types 'const int[int]' for array subscript
   54 |         return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
      |                                    ^
a.cc:54:49: error: invalid types 'const int[int]' for array subscript
   54 |         return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
      |                                                 ^
a.cc:54:68: error: invalid types 'const int[int]' for array subscript
   54 |         return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
      |                                                                    ^
a.cc: In member function 'T Factorial<T>::P(int, int) const':
a.cc:59:37: error: invalid types 'const int[int]' for array subscript
   59 |         return static_cast<T>((facts[p] * factinv[p-q]) % mod);
      |                                     ^
a.cc:59:50: error: invalid types 'const int[int]' for array subscript
   59 |         return static_cast<T>((facts[p] * factinv[p-q]) % mod);
      |                                                  ^
a.cc: At global scope:
a.cc:85:8: error: aggregate 'FFT::ar FFT::root' has incomplete type and cannot be defined
   85 |     ar root;
      |        ^~~~
a.cc:86:9: error: aggregate 'FFT::arr FFT::rev' has incomplete type and cannot be defined
   86 |     arr rev;
      |         ^~~
a.cc: In function 'void FFT::fft(ar&, ar&)':
a.cc:112:38: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  112 |         for (int i = 0; i < N; ++i) f[i] = a[rev[i]];
      |                                      ^
a.cc:116:30: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  116 |                     num z = f[i+j+k]* root[j+k];
      |                              ^
a.cc:117:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  117 |                     f[i+j+k] = f[i+j] - z;
      |                      ^
a.cc:117:33: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  117 |                     f[i+j+k] = f[i+j] - z;
      |                                 ^
a.cc:118:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  118 |                     f[i+j] = f[i+j] + z;
      |                      ^
a.cc:118:31: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int')
  118 |                     f[i+j] = f[i+j] + z;
      |                               ^
a.cc: At global scope:
a.cc:123:8: error: aggregate 'FFT::ar FFT::a' has in