結果
| 問題 |
No.1731 Product of Subsequence
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-11-05 21:48:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 625 ms / 2,000 ms |
| コード長 | 1,120 bytes |
| コンパイル時間 | 4,176 ms |
| コンパイル使用メモリ | 189,628 KB |
| 最終ジャッジ日時 | 2025-01-25 12:09:38 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
int main()
{
int n;cin>>n;
ll k;cin>>k;
if(k==1){
cout<<(mint(2).pow(n)-1).val()<<endl;
return 0;
}
ll a[2020];
for(int i=0; i<n; i++){
cin>>a[i];
a[i]%=k;
}
map<ll, mint> dp;
dp[1]=1;
for(int i=0; i<n; i++){
map<ll, mint> ndp=dp;
for(auto p:dp){
ll g=gcd(k, p.first*a[i]%k);
ndp[g]+=p.second;
}
swap(dp, ndp);
}
cout<<dp[k].val()<<endl;
return 0;
}
chocorusk