/** author: shobonvip created: 2024.11.10 23:02:46 **/ #include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } //defmodfact const int COMinitMAX = 992844; mint fact[COMinitMAX+1], factinv[COMinitMAX+1]; void modfact(){ fact[0] = 1; for (int i=1; i<=COMinitMAX; i++){ fact[i] = fact[i-1] * i; } factinv[COMinitMAX] = fact[COMinitMAX].inv(); for (int i=COMinitMAX-1; i>=0; i--){ factinv[i] = factinv[i+1] * (i+1); } } mint binom(int a, int b){ if (a std::vector poly_inv(std::vector &a, int M = -314159265){ if (M == -314159265) M = (int)a.size(); else if (M <= 0) return {}; int n = a.size(); T r = a[0].pow(T::mod()-2); int m = 1; std::vector res = {r}; while (m < M){ std::vector f = a; f.resize(std::min(n, 2*m)); std::vector h = atcoder::convolution(f, res); for (int i=0; i poly_log(vector &a, int M = -314159265){ if (M == -314159265) M = (int)a.size(); else if (M <= 0) return {}; int n = a.size(); if (n == 1) return vector(M, 0); vector b(n-1); for (int i=0; i t = convolution(b, poly_inv(a, M)); vector ret(M); for (int i=0; i poly_exp(vector &a, int M = -314159265){ if (M == -314159265) M = (int)a.size(); else if (M <= 0) return {}; int n = a.size(); int m = 1; vector res = {1}; while (m < M){ vector f(2*m); for (int i=0; i v = poly_log(res, 2*m); vector w(2*m); for (int i=0; i<2*m; i++) w[i] = f[i] - v[i]; w[0] += 1; vector g = convolution(res, w); res.insert(res.end(), g.begin()+m, g.begin()+2*m); m <<= 1; } res.resize(M); return res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); modfact(); int n, k; cin >> n >> k; vector a(n); rep(i,0,n) cin >> a[i]; vector> logs(k+1, vector(k+1)); rep(i,0,k+1){ rep(j,0,i+1){ logs[i][j] = factinv[j]; } logs[i] = poly_log(logs[i]); } vector tar(k+1); rep(g,1,k+1){ if (k % g == 0) { int l = k / g; vector val(g + 1); rep(i,0,n) { val[min(a[i] / l, g)] += 1; } vector f(g + 1); rep(i,0,g+1) { rep(j,0,g+1){ f[j] += val[i] * logs[i][j]; } } tar[g] = poly_exp(f)[g] * fact[g]; } } mint ans = 0; rep(i,0,k){ int g = __gcd(i, k); ans += tar[g]; } ans /= k; cout << ans.val() << '\n'; }