結果

問題 No.1731 Product of Subsequence
ユーザー umezoumezo
提出日時 2021-11-07 19:34:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 2,548 ms
コンパイル使用メモリ 212,688 KB
実行使用メモリ 32,896 KB
最終ジャッジ日時 2024-04-26 17:56:57
合計ジャッジ時間 18,744 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 66 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 12 ms
11,392 KB
testcase_13 AC 20 ms
11,904 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 20 ms
12,032 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 23 ms
12,160 KB
testcase_25 AC 16 ms
11,904 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 tt=gcd(tmp*A[i-1],k);
      dp[i][m[tt]]=(dp[i][m[tt]]+dp[i-1][m[tmp]])%MOD;
    }
  }
  cout<<dp[n][m[k]]<<endl;

  return 0;
}
0