#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template ostream& operator<<(ostream& os, const set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const unordered_set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const atcoder::segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const atcoder::lazy_segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} using mint = modint998244353; // combination mod prime // https://youtu.be/8uowVvQ_-Mo?t=6002 // https://youtu.be/Tgd_zLfRZOQ?t=9928 struct modinv { int n; vector d; modinv(): n(2), d({0,1}) {} mint operator()(int i) { while (n <= i) d.push_back(-d[mint::mod()%n]*(mint::mod()/n)), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } invs; struct modfact { int n; vector d; modfact(): n(2), d({1,1}) {} mint operator()(int i) { while (n <= i) d.push_back(d.back()*n), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } facts; struct modfactinv { int n; vector d; modfactinv(): n(2), d({1,1}) {} mint operator()(int i) { while (n <= i) d.push_back(d.back()*invs(n)), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } ifacts; mint comb(int n, int k) { if (n < k || k < 0) return 0; return facts(n)*ifacts(k)*ifacts(n-k); } template< typename T > struct FormalPowerSeries : vector< T > { using vector< T >::vector; using P = FormalPowerSeries; template FormalPowerSeries(Args...args): vector(args...) {} FormalPowerSeries(initializer_list a): vector(a.begin(),a.end()) {} using MULT = function< P(P, P) >; static MULT &get_mult() { static MULT mult = [&](P a, P b){ P res(convolution(a, b)); return res; }; return mult; } static void set_fft(MULT f) { get_mult() = f; } void shrink() { while(this->size() && this->back() == T(0)) this->pop_back(); } P operator+(const P &r) const { return P(*this) += r; } P operator+(const T &v) const { return P(*this) += v; } P operator-(const P &r) const { return P(*this) -= r; } P operator-(const T &v) const { return P(*this) -= v; } P operator*(const P &r) const { return P(*this) *= r; } P operator*(const T &v) const { return P(*this) *= v; } P operator/(const P &r) const { return P(*this) /= r; } P operator%(const P &r) const { return P(*this) %= r; } P &operator+=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < int(r.size()); i++) (*this)[i] += r[i]; return *this; } P &operator+=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] += r; return *this; } P &operator-=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < int(r.size()); i++) (*this)[i] -= r[i]; // shrink(); return *this; } P &operator-=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] -= r; // shrink(); return *this; } P &operator*=(const T &v) { const int n = (int) this->size(); for(int k = 0; k < n; k++) (*this)[k] *= v; return *this; } P &operator*=(const P &r) { if(this->empty() || r.empty()) { this->clear(); return *this; } assert(get_mult() != nullptr); return *this = get_mult()(*this, r); } P &operator%=(const P &r) { return *this -= *this / r * r; } P operator-() const { P ret(this->size()); for(int i = 0; i < int(this->size()); i++) ret[i] = -(*this)[i]; return ret; } P &operator/=(const P &r) { if(this->size() < r.size()) { this->clear(); return *this; } int n = this->size() - r.size() + 1; return *this = (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n); } P pre(int sz) const { return P(begin(*this), begin(*this) + min((int) this->size(), sz)); } P operator>>(int sz) const { if((int)this->size() <= sz) return {}; P ret(*this); ret.erase(ret.begin(), ret.begin() + sz); return ret; } P operator<<(int sz) const { P ret(*this); ret.insert(ret.begin(), sz, T(0)); return ret; } P rev(int deg = -1) const { P ret(*this); if(deg != -1) ret.resize(deg, T(0)); reverse(begin(ret), end(ret)); return ret; } P diff() const { const int n = (int) this->size(); P ret(max(0, n - 1)); for(int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i); return ret; } P integral() const { const int n = (int) this->size(); P ret(n + 1); ret[0] = T(0); for(int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1); return ret; } // F(0) must not be 0 P inv(int deg = -1) const { assert(((*this)[0]) != T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1) / (*this)[0]}); for(int i = 1; i < deg; i <<= 1) { ret = (ret + ret - ret * ret * pre(i << 1)).pre(i << 1); } return ret.pre(deg); } /* P inv_special(int k, int deg = -1) const { // ret = 0 + x/f_1 P ret({0, T(k)}); for(int i = 1; (i >> 1) < deg; i <<= 1) { // F(G_i(x)) P fg = (((-ret.pow(k, i << 1) + T(1)) * ret).pre(i << 1) * (-ret + T(1)).inv(i << 1)).pre(i << 1) * T(k).inv(); // G_(i + 1)(x) = G_i(x) - (F(G_i(x)) - x) / F'(G_i(x)) // G_(i + 1)(x) = G_i(x) - (F(G_i(x)) - x) / ((d/dx)F(G_i(x)) / (d/dx)G_i(x)) ret = (ret - ((fg - P{0, 1}) * ret.diff()).pre(i << 1) * (fg.diff()).inv(i << 1)).pre(i << 1); } return ret.pre(deg); } */ // F(0) must be 1 P log(int deg = -1) const { assert((*this)[0] == T(1)); const int n = (int) this->size(); if(deg == -1) deg = n; return (this->diff() * this->inv(deg)).pre(deg - 1).integral(); } P sqrt(int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; if((*this)[0] == T(0)) { for(int i = 1; i < n; i++) { if((*this)[i] != T(0)) { if(i & 1) return {}; if(deg - i / 2 <= 0) break; auto ret = (*this >> i).sqrt(deg - i / 2) << (i / 2); if(int(ret.size()) < deg) ret.resize(deg, T(0)); return ret; } } return P(deg, 0); } P ret({T(1)}); T inv2 = T(1) / T(2); for(int i = 1; i < deg; i <<= 1) { ret = (ret + pre(i << 1) * ret.inv(i << 1)) * inv2; } return ret.pre(deg); } // F(0) must be 0 P exp(int deg = -1) const { assert((*this)[0] == T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1)}); for(int i = 1; i < deg; i <<= 1) { ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1); } return ret.pre(deg); } P pow(int k, int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; for(int i = 0; i < n; i++) { if((*this)[i] != T(0)) { T rev = T(1) / (*this)[i]; P C(*this * rev); P D(n - i); for(int j = i; j < n; j++) D[j - i] = C[j]; D = (D.log(deg) * T(k)).exp() * (*this)[i].pow(k); P E(deg); if(i * k > deg) return E; auto S = i * k; for(int j = 0; j + S < deg && j < D.size(); j++) E[j + S] = D[j]; return E; } } return *this; } P taylor_shift(T x) const { const int n = (int) this->size(); P p(n), q(n); for(int i = 0; i < n; i++) p[i] = facts(i) * (*this)[i]; for(int i = 0; i < n; i++) q[i] = ifacts(n - 1 - i) * x.pow(n - 1 - i); p *= q; p = p >> (n - 1); for(int i = 0; i < n; i++) p[i] *= ifacts(i); return p; } T get(int idx){ assert(idx >= 0); if(idx < int(this->size())) return (*this)[idx]; else return T(0); } void set(int idx, T x){ assert(idx >= 0); if(idx < int(this->size())) (*this)[idx] = x; else{ this->resize(idx + 1); T(0); } return; } T eval(T x) const { T r = 0, w = 1; for(auto &v : *this) { r += w * v; w *= x; } return r; } }; template T Bostan_Mori(FormalPowerSeries P, FormalPowerSeries Q, ll n){ assert(P.size() == Q.size()); if(n == 0) return P[0] / Q[0]; const int k = P.size(); FormalPowerSeries R = Q; rep(i, k) if(i % 2 == 1) R[i] *= (T)-1; P *= R; Q *= R; FormalPowerSeries U(k), V(k); if(n % 2 == 1) rep(i, k - 1) U[i] = P[2 * i + 1]; else rep(i, k) U[i] = P[2 * i]; rep(i, k) V[i] = Q[2 * i]; return Bostan_Mori(U, V, n / 2); } // C = A * B in the full_relaxed way // c_i = \sigma_{j = 0}^{i} a_{j} b_{i - j} // Postulate: at the point of i, all of the a_j, b_j (0 <= j <= i) are known // O(N(longN)^2) // 5e5 * 5e5 -> 3300 ms // https://judge.yosupo.jp/submission/167521 template void convolution_online(FormalPowerSeries& a, FormalPowerSeries& b, FormalPowerSeries& c, int idx){ assert(int(c.size()) >= int(a.size()) + int(b.size()) - 1); int two = 1; rep(_, 30){ if(idx == 0 and two >= 2) break; if(!(idx % two == max(0, two - 2))) break; { FormalPowerSeries a1(two), b1(two), c1; rep(i, two){a1[i] = a[(two - 1) + i]; b1[i] = b[idx - (two - 1) + i];} c1 = a1 * b1; rep(i, two * 2 - 1) c[idx + i] += c1[i]; } if(idx == (two - 1) * 2) break; { FormalPowerSeries a2(two), b2(two), c2; rep(i, two){a2[i] = a[idx - (two - 1) + i]; b2[i] = b[(two - 1) + i];} c2 = a2 * b2; rep(i, two * 2 - 1) c[idx + i] += c2[i]; } two *= 2; } } template struct Merger{ int n; using P = FormalPowerSeries; using Comp = std::function; Comp comp = [](const P& a, const P& b){return a.size() > b.size();}; priority_queue, Comp> pq; Merger(int n = -1) : n(n), pq(comp){ pq.push(P{1}); } void add(P r){ pq.push(r); } P get(){ while(pq.size() > 1){ auto f = pq.top(); pq.pop(); auto g = pq.top(); pq.pop(); f *= g; if(n != -1) if(int(f.size()) > n) f.resize(n); pq.push(f); } P res = pq.top(); return res; } }; using FPS = FormalPowerSeries; int main(){ int n, K; cin >> n >> K; mint ans = 0; map frequency_a; rep(i, n){ int a; cin >> a; frequency_a[min(a, K)]++; } map frequency_p; for(int r = 1; r <= K; r++){ int p = gcd(K, r); frequency_p[p]++; } vector f(K + 1); f[0] = {1}; for(int k = 1; k <= K; k++){ f[k] = f[k - 1]; f[k].push_back(ifacts(k)); } for(auto [p, c] : frequency_p){ int q = K / p; Merger merger(p + 1); map frequency_b; for(auto [a, cnt] : frequency_a){ int b = min(a / q, p); frequency_b[b] += cnt; } for(auto [b, cnt] : frequency_b){ merger.add(f[b].pow(cnt, p + 1)); } auto res = merger.get(); if(int(res.size()) > p) ans += res[p] * facts(p) * c; } cout << ans / K << "\n"; return 0; }