結果
| 問題 | No.1731 Product of Subsequence | 
| コンテスト | |
| ユーザー |  houren | 
| 提出日時 | 2021-11-05 22:41:59 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,419 bytes | 
| コンパイル時間 | 1,988 ms | 
| コンパイル使用メモリ | 177,080 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-06 13:42:38 | 
| 合計ジャッジ時間 | 3,292 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 8 WA * 23 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
int main(){
    ll n,k,k2,foc = 0;
    cin >> n >> k;
    if(k==1){
        ll ans = 1;
        rep(i,n) ans = ans * 2 % MOD;
        cout << (ans - 1 + MOD) % MOD << endl;
        return 0;
    }
    k2 = k;
    vector<vector<ll>> dp;
    vector<ll> div;
    vector<int> siz;
    for(ll i=2;i*i<=k;i++){
        if(!(k2%i)){
            div.push_back(i);
            siz.push_back(1);
            dp.push_back({1});
            while(!(k2%i)){
                k2 /= i;
                dp[foc].push_back(0);
                siz[foc]++;
            }
            foc++;
        }
    }
    if(k2!=1){
        div.push_back(k2);
        siz.push_back(2);
        dp.push_back({1,0});
        foc++;
    }
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,foc){
            int cnt = 0;
            while(!(a%div[j])){
                cnt++;
                a /= div[j];
            }
            if(!cnt) continue;
            for(int k=siz[j]-1;k>=0;k--){
                int update = min(k+cnt, siz[j]-1);
                dp[j][update] = (dp[j][update]+dp[j][k]) % MOD;
            }
        }
    }
    ll ans = 1;
    rep(i,foc) ans = ans * dp[i][siz[i]-1] % MOD;
    cout << ans << endl;
    return 0;
}
            
            
            
        