結果
| 問題 | No.1731 Product of Subsequence | 
| コンテスト | |
| ユーザー |  umezo | 
| 提出日時 | 2021-11-07 19:44:22 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 944 bytes | 
| コンパイル時間 | 2,424 ms | 
| コンパイル使用メモリ | 214,352 KB | 
| 最終ジャッジ日時 | 2025-01-25 14:44:06 | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 27 WA * 4 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll dp[2010][2010];
const int MOD=1e9+7;
vector<ll> divisor(ll x){
  set<ll> s;
  for(ll i=1;i*i<=x;i++){
    if(x%i==0){
      s.insert(i);
      s.insert(x/i);
    }
  }
  vector<ll> res;
  for(auto y:s) res.push_back(y);
  sort(ALL(res));
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,k;
  cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  
  vector<ll> D=divisor(k);
  int d=D.size();
  map<ll,ll> m;
  rep(i,d) m[D[i]]=i;
  
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<d;j++){
      ll tmp=D[j];
      dp[i][m[tmp]]=(dp[i][m[tmp]]+dp[i-1][m[tmp]])%MOD;
      ll b=gcd(A[i-1],k);
      ll c=k/b;
      ll a=gcd(c,tmp);
      dp[i][m[a*b]]=(dp[i][m[a*b]]+dp[i-1][m[tmp]])%MOD;
    }
  }
  cout<<dp[n][m[k]]<<endl;
  return 0;
}
            
            
            
        