結果
| 問題 | No.1731 Product of Subsequence | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2024-11-21 09:34:22 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,140 bytes | 
| コンパイル時間 | 2,806 ms | 
| コンパイル使用メモリ | 238,260 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-21 09:34:30 | 
| 合計ジャッジ時間 | 6,560 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 27 WA * 4 | 
ソースコード
#include <bits/extc++.h>
using i64 = long long;
constexpr int P = 1E9 + 7;
inline void Inc(int &x, int y) {
    if ((x += y) >= P) x -= P;
}
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int n;
    i64 m;
    std::cin >> n >> m;
    
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i] = std::__gcd(a[i], m);
    }
    
    auto lcm = [&](int x, int y) {
        return 1ll * x * y / std::__gcd(x, y);
    };
    int cnt = 0;
    __gnu_pbds::gp_hash_table<i64, int> mp;
    std::vector<i64> d;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            d.push_back(i);
            if (i != m / i) d.push_back(m / i);
        }
    }
    std::sort(d.begin(), d.end());
    for (auto x : d) {
        mp[x] = cnt++;
    }
    std::vector<int> f(cnt);
    f[0] = 1;
    for (int i = 0; i < n; i++) {
        std::vector<int> nf(cnt);
        for (auto x : d) {
            Inc(nf[mp[std::__gcd(1ll * m, 1ll * x * a[i])]], f[mp[x]]);
            Inc(nf[mp[x]], f[mp[x]]);
        }
        f = nf;
    }
    std::cout << f[cnt - 1];
    return 0;
}
            
            
            
        