#line 1 "main.cpp" #include #include #line 2 "/home/yasu/Documents/library/library/templates/mydebug.hpp" #ifdef __DEBUG__ void debug_out() { std::cerr << "\n";} template void debug_out(Head H, Tail... T) {std::cerr << H << " "; debug_out(T...);} #define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:\n" , debug_out(__VA_ARGS__) #else #define debug(...) #endif #line 1 "/home/yasu/Documents/library/library/templates/myconst.hpp" const int dx[]={1, 0, -1, 0, 1,-1, 1,-1}; const int dy[]={0, 1, 0, -1, 1, 1,-1,-1}; const int INT_INF = (int)(2e9); const long long int LL_INF = (long long int)(2e18); #line 13 "/home/yasu/Documents/library/library/templates/template.hpp" static std::mt19937 _g(time(nullptr)); inline long long int randint(long long int a, long long int b) { long long int w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); } inline void fast_io() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); }; template inline std::ostream& operator<<(std::ostream& os, const std::pair p) { os << "[" << p.first << ";" << p.second << "]"; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::map p) { for (auto el : p) os << "[" << el.first << ";" << el.second << "]"; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::unordered_map p) { for (auto el : p) os << "[" << el.first << ";" << el.second << "]"; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::vector& v) { for (auto el : v) os << el << " "; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::vector>& v) { for (auto el : v) os << el << "\n"; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::deque& v) { for (auto el : v) os << el << " "; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::queue& v) { for (auto el : v) os << el << " "; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::stack& v) { for (auto el : v) os << el << " "; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::set& v) { for (auto el : v) os << el << " "; return os; } template inline std::ostream& operator<<(std::ostream& os, const std::multiset& v) { for (auto el : v) os << el << " "; return os; } template inline std::istream& operator>>(std::istream& is, std::vector &vec) {for (T &x : vec) is >> x;return is;} template inline std::vector fetch_vec(int sz) { std::vector ret(sz); for (auto& elem : ret) std::cin >> elem; return ret; } template inline bool chmax(T &a, const T &b) { if (a inline bool chmin(T &a, const T &b) { if (b inline std::ostream &operator<<(std::ostream &os, const atcoder::modint1000000007 &x){os << x.val(); return os; } inline std::ostream &operator<<(std::ostream &os, const atcoder::modint998244353 &x){os << x.val(); return os; } #line 4 "main.cpp" using namespace atcoder; using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair; using pll = pair; vector divisor(int64_t n) { vector ret; for (int64_t i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } using mint = modint1000000007; long long solve(int N, long long K, const std::vector &A) { auto divK = divisor(K); // cerr << divK << endl; map mpK; vector vK; for (ll x : divK) { mpK[x] = vK.size(); vK.push_back(x); } vector dp(vK.size()); dp[0] = 1; for (int i = 0; i < N; i++) { vector nxtdp = dp; ll g = gcd(K, A[i]); for (int x = 0; x < vK.size(); x++) { ll k = vK[x]; k *= g; k = gcd(k, K); if (k >= K) { k = K; } int y = mpK[k]; nxtdp[y] += dp[x]; } swap(dp, nxtdp); } return dp[mpK[K]].val(); } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); int N; long long K; std::cin >> N >> K; std::vector A(N); for (int i = 0; i < N; ++i) { std::cin >> A[i]; A[i] %= K; } auto ans = solve(N, K, A); std::cout << ans << '\n'; return 0; }