#include #include using namespace std; using namespace atcoder; typedef modint1000000007 mint; typedef long long ll; vector> pfact(int n){ vector> ret; for (int i=2; i*i<=n; i++){ if (n%i == 0){ int cnt = 0; while (n%i == 0){ n /= i; cnt++; } ret.push_back(pair(i, cnt)); } } if (n > 1) ret.push_back(pair(n, 1)); return ret; } int main(){ int n, k; cin >> n >> k; vector> pf = pfact(k); vector pl; for (auto [p,c]: pf){ pl.push_back(p); } vector a(n); for (int i=0; i> a[i]; ll nw = 1; for (int j: pl){ while (a[i] % j == 0){ nw *= j; a[i] /= j; } } a[i] = nw % k; } map s; s[1] = 1; for (int i=0; i ns = s; for (auto j=s.begin(); j!=s.end(); j++){ int tmp = (ll)j->first * a[i] % k; if (ns.find(tmp) == ns.end()){ ns[tmp] = 0; } ns[tmp] += j->second; } s = ns; } if (s.find(0) == s.end()){ s[0] = 0; } cout << s[0].val() << endl; }