結果
| 問題 | No.1731 Product of Subsequence | 
| コンテスト | |
| ユーザー |  hiro71687k | 
| 提出日時 | 2023-03-31 00:43:01 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 881 bytes | 
| コンパイル時間 | 4,500 ms | 
| コンパイル使用メモリ | 259,876 KB | 
| 最終ジャッジ日時 | 2025-02-11 19:25:23 | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 27 WA * 4 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=999999999999999999;
ll gcd(ll a, ll b) {
	a = abs(a); b = abs(b);
	if (a < b)swap(a, b);
	while (b) {
	    ll r=a%b;
        a=b;
	    b=r;
	}
	return a;
}
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]=gcd(k,a[i]);
    }
    vector<map<ll,ll>>dp(n);
    dp[0][1]=1;
    ll x=gcd(k,a[0]);
    dp[0][x]+=1;
    for (ll i = 1; i < n; i++)
    {
        for(auto v:dp[i-1]){
            dp[i][v.first]+=v.second;
            dp[i][v.first]%=mod;
            ll z=v.first*a[i];
            z=gcd(k,z);
            dp[i][z]+=v.second;
            dp[i][z]%=mod;
        }
    }
    cout << dp[n-1][k] << endl;
}
            
            
            
        