結果

問題 No.1783 Remix Sum
ユーザー 👑 hos.lyrichos.lyric
提出日時 2021-12-12 03:14:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,789 ms / 10,000 ms
コード長 15,950 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 113,380 KB
実行使用メモリ 44,468 KB
最終ジャッジ日時 2023-09-27 17:44:21
合計ジャッジ時間 61,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,960 KB
testcase_01 AC 15 ms
11,712 KB
testcase_02 AC 15 ms
11,984 KB
testcase_03 AC 16 ms
16,096 KB
testcase_04 AC 57 ms
11,764 KB
testcase_05 AC 57 ms
11,784 KB
testcase_06 AC 215 ms
15,852 KB
testcase_07 AC 1,471 ms
34,820 KB
testcase_08 AC 387 ms
22,076 KB
testcase_09 AC 388 ms
22,052 KB
testcase_10 AC 58 ms
11,864 KB
testcase_11 AC 57 ms
11,756 KB
testcase_12 AC 1,474 ms
34,724 KB
testcase_13 AC 1,470 ms
34,736 KB
testcase_14 AC 389 ms
22,052 KB
testcase_15 AC 1,768 ms
43,988 KB
testcase_16 AC 1,474 ms
34,796 KB
testcase_17 AC 1,467 ms
34,676 KB
testcase_18 AC 57 ms
11,780 KB
testcase_19 AC 385 ms
22,048 KB
testcase_20 AC 560 ms
28,244 KB
testcase_21 AC 372 ms
22,032 KB
testcase_22 AC 368 ms
21,992 KB
testcase_23 AC 416 ms
28,184 KB
testcase_24 AC 520 ms
28,244 KB
testcase_25 AC 214 ms
15,956 KB
testcase_26 AC 1,472 ms
34,684 KB
testcase_27 AC 213 ms
15,884 KB
testcase_28 AC 214 ms
15,860 KB
testcase_29 AC 560 ms
28,140 KB
testcase_30 AC 557 ms
28,256 KB
testcase_31 AC 387 ms
22,028 KB
testcase_32 AC 1,762 ms
43,932 KB
testcase_33 AC 560 ms
28,288 KB
testcase_34 AC 573 ms
28,484 KB
testcase_35 AC 1,483 ms
35,124 KB
testcase_36 AC 1,778 ms
44,324 KB
testcase_37 AC 1,775 ms
44,468 KB
testcase_38 AC 1,481 ms
35,192 KB
testcase_39 AC 574 ms
28,504 KB
testcase_40 AC 226 ms
16,216 KB
testcase_41 AC 571 ms
28,412 KB
testcase_42 AC 571 ms
28,452 KB
testcase_43 AC 1,480 ms
35,128 KB
testcase_44 AC 104 ms
12,016 KB
testcase_45 AC 232 ms
16,128 KB
testcase_46 AC 400 ms
22,384 KB
testcase_47 AC 572 ms
28,404 KB
testcase_48 AC 1,482 ms
35,352 KB
testcase_49 AC 1,775 ms
44,384 KB
testcase_50 AC 103 ms
12,040 KB
testcase_51 AC 231 ms
16,076 KB
testcase_52 AC 400 ms
22,396 KB
testcase_53 AC 571 ms
28,404 KB
testcase_54 AC 1,485 ms
35,188 KB
testcase_55 AC 1,789 ms
44,464 KB
testcase_56 AC 106 ms
11,972 KB
testcase_57 AC 232 ms
16,184 KB
testcase_58 AC 400 ms
22,392 KB
testcase_59 AC 571 ms
28,484 KB
testcase_60 AC 1,340 ms
35,124 KB
testcase_61 AC 1,777 ms
44,432 KB
testcase_62 AC 103 ms
12,156 KB
testcase_63 AC 231 ms
16,240 KB
testcase_64 AC 400 ms
22,212 KB
testcase_65 AC 572 ms
28,516 KB
testcase_66 AC 1,484 ms
35,016 KB
testcase_67 AC 36 ms
12,808 KB
testcase_68 AC 71 ms
12,132 KB
testcase_69 AC 228 ms
16,120 KB
testcase_70 AC 397 ms
22,220 KB
testcase_71 AC 571 ms
28,508 KB
testcase_72 AC 1,484 ms
35,184 KB
testcase_73 AC 1,329 ms
42,964 KB
testcase_74 AC 71 ms
11,980 KB
testcase_75 AC 229 ms
16,128 KB
testcase_76 AC 399 ms
22,360 KB
testcase_77 AC 571 ms
28,412 KB
testcase_78 AC 1,483 ms
35,352 KB
testcase_79 AC 818 ms
43,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }

////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
  static constexpr unsigned M = M_;
  unsigned x;
  constexpr ModInt() : x(0U) {}
  constexpr ModInt(unsigned x_) : x(x_ % M) {}
  constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
  constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// M: prime, G: primitive root, 2^K | M - 1
template <unsigned M_, unsigned G_, int K_> struct Fft {
  static_assert(2U <= M_, "Fft: 2 <= M must hold.");
  static_assert(M_ < 1U << 30, "Fft: M < 2^30 must hold.");
  static_assert(1 <= K_, "Fft: 1 <= K must hold.");
  static_assert(K_ < 30, "Fft: K < 30 must hold.");
  static_assert(!((M_ - 1U) & ((1U << K_) - 1U)), "Fft: 2^K | M - 1 must hold.");
  static constexpr unsigned M = M_;
  static constexpr unsigned M2 = 2U * M_;
  static constexpr unsigned G = G_;
  static constexpr int K = K_;
  ModInt<M> FFT_ROOTS[K + 1], INV_FFT_ROOTS[K + 1];
  ModInt<M> FFT_RATIOS[K], INV_FFT_RATIOS[K];
  Fft() {
    const ModInt<M> g(G);
    for (int k = 0; k <= K; ++k) {
      FFT_ROOTS[k] = g.pow((M - 1U) >> k);
      INV_FFT_ROOTS[k] = FFT_ROOTS[k].inv();
    }
    for (int k = 0; k <= K - 2; ++k) {
      FFT_RATIOS[k] = -g.pow(3U * ((M - 1U) >> (k + 2)));
      INV_FFT_RATIOS[k] = FFT_RATIOS[k].inv();
    }
    assert(FFT_ROOTS[1] == M - 1U);
  }
  // as[rev(i)] <- \sum_j \zeta^(ij) as[j]
  void fft(ModInt<M> *as, int n) const {
    assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
    int m = n;
    if (m >>= 1) {
      for (int i = 0; i < m; ++i) {
        const unsigned x = as[i + m].x;  // < M
        as[i + m].x = as[i].x + M - x;  // < 2 M
        as[i].x += x;  // < 2 M
      }
    }
    if (m >>= 1) {
      ModInt<M> prod = 1U;
      for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
        for (int i = i0; i < i0 + m; ++i) {
          const unsigned x = (prod * as[i + m]).x;  // < M
          as[i + m].x = as[i].x + M - x;  // < 3 M
          as[i].x += x;  // < 3 M
        }
        prod *= FFT_RATIOS[__builtin_ctz(++h)];
      }
    }
    for (; m; ) {
      if (m >>= 1) {
        ModInt<M> prod = 1U;
        for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
          for (int i = i0; i < i0 + m; ++i) {
            const unsigned x = (prod * as[i + m]).x;  // < M
            as[i + m].x = as[i].x + M - x;  // < 4 M
            as[i].x += x;  // < 4 M
          }
          prod *= FFT_RATIOS[__builtin_ctz(++h)];
        }
      }
      if (m >>= 1) {
        ModInt<M> prod = 1U;
        for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
          for (int i = i0; i < i0 + m; ++i) {
            const unsigned x = (prod * as[i + m]).x;  // < M
            as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x;  // < 2 M
            as[i + m].x = as[i].x + M - x;  // < 3 M
            as[i].x += x;  // < 3 M
          }
          prod *= FFT_RATIOS[__builtin_ctz(++h)];
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x;  // < 2 M
      as[i].x = (as[i].x >= M) ? (as[i].x - M) : as[i].x;  // < M
    }
  }
  // as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
  void invFft(ModInt<M> *as, int n) const {
    assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
    int m = 1;
    if (m < n >> 1) {
      ModInt<M> prod = 1U;
      for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
        for (int i = i0; i < i0 + m; ++i) {
          const unsigned long long y = as[i].x + M - as[i + m].x;  // < 2 M
          as[i].x += as[i + m].x;  // < 2 M
          as[i + m].x = (prod.x * y) % M;  // < M
        }
        prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
      }
      m <<= 1;
    }
    for (; m < n >> 1; m <<= 1) {
      ModInt<M> prod = 1U;
      for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
        for (int i = i0; i < i0 + (m >> 1); ++i) {
          const unsigned long long y = as[i].x + M2 - as[i + m].x;  // < 4 M
          as[i].x += as[i + m].x;  // < 4 M
          as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x;  // < 2 M
          as[i + m].x = (prod.x * y) % M;  // < M
        }
        for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
          const unsigned long long y = as[i].x + M - as[i + m].x;  // < 2 M
          as[i].x += as[i + m].x;  // < 2 M
          as[i + m].x = (prod.x * y) % M;  // < M
        }
        prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
      }
    }
    if (m < n) {
      for (int i = 0; i < m; ++i) {
        const unsigned y = as[i].x + M2 - as[i + m].x;  // < 4 M
        as[i].x += as[i + m].x;  // < 4 M
        as[i + m].x = y;  // < 4 M
      }
    }
    const ModInt<M> invN = ModInt<M>(n).inv();
    for (int i = 0; i < n; ++i) {
      as[i] *= invN;
    }
  }
  void fft(vector<ModInt<M>> &as) const {
    fft(as.data(), as.size());
  }
  void invFft(vector<ModInt<M>> &as) const {
    invFft(as.data(), as.size());
  }
  vector<ModInt<M>> convolve(vector<ModInt<M>> as, vector<ModInt<M>> bs) const {
    if (as.empty() || bs.empty()) return {};
    const int len = as.size() + bs.size() - 1;
    int n = 1;
    for (; n < len; n <<= 1) {}
    as.resize(n); fft(as);
    bs.resize(n); fft(bs);
    for (int i = 0; i < n; ++i) as[i] *= bs[i];
    invFft(as);
    as.resize(len);
    return as;
  }
  vector<ModInt<M>> square(vector<ModInt<M>> as) const {
    if (as.empty()) return {};
    const int len = as.size() + as.size() - 1;
    int n = 1;
    for (; n < len; n <<= 1) {}
    as.resize(n); fft(as);
    for (int i = 0; i < n; ++i) as[i] *= as[i];
    invFft(as);
    as.resize(len);
    return as;
  }
};

constexpr unsigned MO = 120586241;
using Mint = ModInt<MO>;
const Fft<MO, 6, 20> FFT;
constexpr Mint G = 9142366;


constexpr int LIM = 1 << 19;
Mint inv[LIM], fac[LIM], invFac[LIM];

void prepare() {
  inv[1] = 1;
  for (int i = 2; i < LIM; ++i) {
    inv[i] = -((Mint::M / i) * inv[Mint::M % i]);
  }
  fac[0] = invFac[0] = 1;
  for (int i = 1; i < LIM; ++i) {
    fac[i] = fac[i - 1] * i;
    invFac[i] = invFac[i - 1] * inv[i];
  }
}
Mint binom(Int n, Int k) {
  if (n < 0) {
    if (k >= 0) {
      return ((k & 1) ? -1 : +1) * binom(-n + k - 1, k);
    } else if (n - k >= 0) {
      return (((n - k) & 1) ? -1 : +1) * binom(-k - 1, n - k);
    } else {
      return 0;
    }
  } else {
    if (0 <= k && k <= n) {
      assert(n < LIM);
      return fac[n] * invFac[k] * invFac[n - k];
    } else {
      return 0;
    }
  }
}


constexpr int TEN[] = {
  1,
  10,
  100,
  1000,
  10000,
  100000,
};


int N, K, T;
Int M;
vector<int> A;


constexpr int MAX_LEN = 1 << 19;
int zw[MAX_LEN];
Mint zas[5][MAX_LEN], zbs[5][MAX_LEN], zcs[5][MAX_LEN];
vector<Mint> multiMul(const vector<Mint> &as, const vector<Mint> &bs, int na = -1, int nb = -1) {
  if (!~na) na = as.size();
  if (!~nb) nb = bs.size();
  chmin(na, TEN[T]);
  chmin(nb, TEN[T]);
  assert((int)as.size() >= na);
  assert((int)bs.size() >= nb);
  const int nc = min(na + nb, TEN[T]);
  int len = 1;
  for (; len < na + nb; len <<= 1) {}
  for (int t = 0; t < T; ++t) {
    fill(zas[t], zas[t] + len, 0);
    fill(zbs[t], zbs[t] + len, 0);
    fill(zcs[t], zcs[t] + len, 0);
  }
  for (int h = 0; h < na; ++h) {
    zas[zw[h]][h] += as[h];
  }
  for (int h = 0; h < nb; ++h) {
    zbs[zw[h]][h] += bs[h];
  }
  for (int t = 0; t < T; ++t) {
    FFT.fft(zas[t], len);
    FFT.fft(zbs[t], len);
  }
  for (int ta = 0; ta < T; ++ta) for (int tb = 0; tb < T; ++tb) {
    const int t = (ta + tb) % T;
    for (int h = 0; h < len; ++h) {
      zcs[t][h] += zas[ta][h] * zbs[tb][h];
    }
  }
  for (int t = 0; t < T; ++t) {
    FFT.invFft(zcs[t], len);
  }
  vector<Mint> cs(nc, 0);
  for (int h = 0; h < nc; ++h) {
    cs[h] = zcs[zw[h]][h];
  }
  return cs;
}

// TODO: save FFT...
// b <- b - (a b - 1) b
vector<Mint> multiInv(const vector<Mint> &as, int n) {
  vector<Mint> bs(n, 0);
  bs[0] = 1;
  for (int m = 1; m < n; m <<= 1) {
    auto cs = multiMul(as, bs, m << 1, m);
    cs[0] -= 1;
    cs = multiMul(cs, bs, -1, m);
    for (int h = m; h < m << 1 && h < n; ++h) bs[h] -= cs[h];
  }
  return bs;
}

// D log(a) = (D a) / a
vector<Mint> multiLog(const vector<Mint> &as, int n) {
  chmin(n, TEN[T]);
  assert((int)as.size() >= n);
  assert(as[0] == 1);
  vector<Mint> bs(n, 0);
  for (int h = 0; h < n; ++h) bs[h] = h * as[h];
  bs = multiMul(bs, multiInv(as, n));
  for (int h = 1; h < n; ++h) bs[h] *= inv[h];
  return bs;
}

// b <- b - (I (c (D b - b D (a mod x^m)) + D (a mod x^m)) - a) b
// c <- c - (b c - 1) c
vector<Mint> multiExp(const vector<Mint> &as, int n) {
// cerr<<"  multiExp n = "<<n<<", as = ";pv(as.begin(),as.end());
  chmin(n, TEN[T]);
  assert((int)as.size() >= n);
  assert(as[0] == 0);
  vector<Mint> Das(n);
  for (int h = 0; h < n; ++h) {
    Das[h] = h * as[h];
  }
  vector<Mint> bs(n, 0), cs(n, 0);
  bs[0] = cs[0] = 1;
  for (int m = 1; m < n; m <<= 1) {
    vector<Mint> Dbs(m);
    for (int h = 0; h < m; ++h) Dbs[h] = h * bs[h];
    auto ds = multiMul(bs, Das, m, m);
    for (int h = 0; h < (int)ds.size(); ++h) ds[h] *= -1;
    for (int h = 0; h < m; ++h) ds[h] += Dbs[h];
    ds = multiMul(cs, ds, m, -1);
    for (int h = 0; h < m; ++h) ds[h] += Das[h];
    for (int h = 0; h < (int)ds.size(); ++h) ds[h] *= inv[h];
    for (int h = 0; h < m << 1 && h < n; ++h) ds[h] -= as[h];
    ds = multiMul(ds, bs, -1, m);
    for (int h = m; h < m << 1 && h < n; ++h) bs[h] -= ds[h];
    
    ds = multiMul(bs, cs, m << 1, m);
    ds[0] -= 1;
    ds = multiMul(ds, cs, -1, m);
    for (int h = m; h < m << 1 && h < n; ++h) cs[h] -= ds[h];
  }
// cerr<<"  multiExp bs = ";pv(bs.begin(),bs.end());
// cerr<<"  multiExp cs = ";pv(cs.begin(),cs.end());
  return bs;
}

vector<Mint> multiPow(vector<Mint> as, Int e) {
// cerr<<"multiPow e = "<<e<<", as = ";pv(as.begin(),as.end());
  if (T == 0) {
    return {as[0].pow(e)};
  } else {
    if (as[0]) {
      const Mint a0e = as[0].pow(e);
      const Mint invA0 = as[0].inv();
      for (int h = 0; h < TEN[T]; ++h) {
        as[h] *= invA0;
      }
      as = multiLog(as, TEN[T]);
      for (int h = 0; h < TEN[T]; ++h) {
        as[h] *= e;
      }
      as = multiExp(as, TEN[T]);
      for (int h = 0; h < TEN[T]; ++h) {
        as[h] *= a0e;
      }
// cerr<<"multiPow return ";pv(as.begin(),as.end());
      return as;
    } else {
      if (e >= T * (10 - 1)) {
        return vector<Mint>(TEN[T], 0);
      }
      vector<Mint> bs(TEN[T], 0);
      bs[0] = 1;
      for (; e; e >>= 1) {
        if (e & 1) bs = multiMul(bs, as);
        as = multiMul(as, as);
      }
      return bs;
    }
  }
}


Mint GG[10][10], invGG[10][10];
void dft(vector<Mint> &as) {
  Mint work0[10], work1[10];
  for (int k = T; k < K; ++k) {
    for (int h = 0; h < TEN[K]; ++h) if (h / TEN[k] % 10 == 0) {
      for (int i = 0; i < 10; ++i) {
        work0[i] = as[h + TEN[k] * i];
      }
      for (int i = 0; i < 10; ++i) {
        work1[i] = 0;
        for (int j = 0; j < 10; ++j) {
          work1[i] += GG[i][j] * work0[j];
        }
      }
      for (int i = 0; i < 10; ++i) {
        as[h + TEN[k] * i] = work1[i];
      }
    }
  }
}
void invDft(vector<Mint> &as) {
  Mint work0[10], work1[10];
  for (int k = T; k < K; ++k) {
    for (int h = 0; h < TEN[K]; ++h) if (h / TEN[k] % 10 == 0) {
      for (int i = 0; i < 10; ++i) {
        work0[i] = as[h + TEN[k] * i];
      }
      for (int i = 0; i < 10; ++i) {
        work1[i] = 0;
        for (int j = 0; j < 10; ++j) {
          work1[i] += invGG[i][j] * work0[j];
        }
      }
      for (int i = 0; i < 10; ++i) {
        as[h + TEN[k] * i] = work1[i];
      }
    }
  }
  const Mint c = Mint(TEN[K - T]).inv();
  for (int h = 0; h < TEN[K]; ++h) {
    as[h] *= c;
  }
}


int main() {
  prepare();
  
// cerr<<G.pow(2)<<" "<<G.pow(5)<<" "<<G.pow(10)<<endl;
  for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) {
    GG[i][j] = G.pow(i * j);
    invGG[i][j] = GG[i][j].inv();
  }
  
  for (; ~scanf("%d%d%lld%d", &N, &K, &M, &T); ) {
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &A[i]);
    }
    
    memset(zw, 0, sizeof(zw));
    for (int h = 0; h < TEN[T]; ++h) {
      for (int t = 1; t < T; ++t) {
        zw[h] += h / TEN[t];
      }
      zw[h] %= max(T, 1);
    }
// cerr<<"zw = ";pv(zw,zw+TEN[T]);
    
    vector<Mint> fs(TEN[K], 0);
    for (int i = 0; i < N; ++i) {
      fs[A[i]] += 1;
    }
    
    dft(fs);
    for (int h0 = 0; h0 < TEN[K]; h0 += TEN[T]) {
      const auto res = multiPow(vector<Mint>(fs.begin() + h0, fs.begin() + h0 + TEN[T]), M);
      for (int i = 0; i < TEN[T]; ++i) {
        fs[h0 + i] = res[i];
      }
    }
    invDft(fs);
    
    for (int h = 0; h < TEN[K]; ++h) {
      printf("%u\n", fs[h].x);
    }
#ifdef LOCAL
cout<<"===="<<endl;
#endif
    
if(T==2){
 vector<Mint>waf(100,0);
 waf[1]=1;
 waf[10]=2;
 multiExp(waf,100);
}
  }
  return 0;
}
0