結果
問題 | No.1731 Product of Subsequence |
ユーザー |
![]() |
提出日時 | 2024-11-11 17:40:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 580 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 2,480 ms |
コンパイル使用メモリ | 205,504 KB |
最終ジャッジ日時 | 2025-02-25 03:55:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include <atcoder/modint> using mint = atcoder::modint1000000007; int main() { fast_io(); int n, k; cin >> n >> k; map<int, mint> dp; dp[1] = 1; for (int i = 0; i < n; i++) { long long a; cin >> a; long long g = gcd(a, k); map<int, mint> new_dp; for (auto [key, val] : dp) { new_dp[key] += val; long long k_new = gcd(g * key, k); new_dp[k_new] += val; } swap(dp, new_dp); } mint ans = dp[k]; if (k == 1) { ans--; } cout << ans.val() << endl; }