#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #include #include #include #include #include #include using namespace std; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; int K; cin >> N >> K; vector> fac; int len = 1; for (int p = 2; p * p <= K; ++p) { if (K % p) continue; fac.emplace_back(p, 0); while (K % p == 0) { K /= p; ++fac.back().second; } len *= 1 + fac.back().second; } if (K > 1) fac.emplace_back(K, 1), len *= 2; vector dp(len); dp.front() = 1; map, int> mp; while (N--) { long long a; cin >> a; vector ds; for (auto [p, deg] : fac) { int m = 0; while (a % p == 0) a /= p, ++m; ds.push_back(min(m, deg)); } mp[ds]++; } for (auto [ds, cnt] : mp) { vector to(dp.size(), -1); auto rec = [&](auto &&self, int d, int prv, int nxt) -> void { if (d == int(fac.size())) { to.at(prv) = nxt; } else { int m = fac.at(d).second; REP(h, m + 1) { self(self, d + 1, prv * (m + 1) + h, nxt * (m + 1) + min(m, ds.at(d) + h)); } } }; rec(rec, 0, 0, 0); while (cnt--) IREP(i, dp.size()) dp.at(to.at(i)) += dp.at(i); } dp.front() -= 1; cout << dp.back().val() << endl; }