結果
| 問題 | No.1731 Product of Subsequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-05 23:13:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,499 bytes |
| 記録 | |
| コンパイル時間 | 2,136 ms |
| コンパイル使用メモリ | 187,460 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 14:27:22 |
| 合計ジャッジ時間 | 11,349 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
const ll MOD = 1000000007;
ll N, K;
ll A[2020];
map<vector<ll>, ll> dp[2];
void print(vector<ll> v) {
REP(i, v.size()) cout << v[i] << " ";
cout << endl;
}
void solve() {
cin >> N >> K;
REP(i, N) cin >> A[i];
map<ll,ll> D;
for (ll i = 2; i * i <= K; ++i) {
while (K % i == 0) D[i] += 1, K /= i;
}
if (K > 1) D[K] += 1;
vector<ll> keys;
vector<ll> vals;
for (const auto &item : D) {
keys.push_back(item.first);
vals.push_back(item.second);
}
vector<ll> y;
REP(i, keys.size()) y.push_back(0);
dp[0][y] = 1;
int cur = 0, tar = 1;
REP(i, N) {
dp[tar].clear();
for (auto hoge = begin(dp[cur]); hoge != end(dp[cur]); ++hoge) {
dp[tar][hoge->first] = hoge->second;
}
vector<ll> x;
for (const auto &item : D) {
ll tmp = 0;
while (A[i] % item.first == 0) tmp++, A[i] /= item.first;
x.push_back(tmp);
}
for (auto hoge = begin(dp[cur]); hoge != end(dp[cur]); ++hoge) {
REP(j, keys.size()) y[j] = min(x[j] + hoge->first[j], vals[j]);
(dp[tar][y] += hoge->second) %= MOD;
}
swap(cur, tar);
}
cout << dp[cur][vals] << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}