結果
問題 |
No.1731 Product of Subsequence
|
ユーザー |
![]() |
提出日時 | 2021-11-07 19:27:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 871 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 210,216 KB |
最終ジャッジ日時 | 2025-01-25 14:42:36 |
ジャッジサーバーID (参考情報) |
judge8 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 WA * 27 |
ソースコード
#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-1][m[tmp]]; ll tt=gcd(tmp*A[i-1],k); dp[i][m[tt]]+=dp[i-1][m[tmp]]; } } cout<<dp[n][m[k]]<<endl; return 0; }