結果
問題 | No.1731 Product of Subsequence |
ユーザー |
|
提出日時 | 2021-11-05 21:46:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 522 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 923 ms |
コンパイル使用メモリ | 81,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 04:34:35 |
合計ジャッジ時間 | 6,385 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main() | ^~~~
ソースコード
#include<iostream>#include<map>#include<atcoder/modint>using namespace std;using mint=atcoder::modint1000000007;long gcdl(long a,long b){return b?gcdl(b,a%b):a;}int gcd(int a,int b){return b?gcd(b,a%b):a;}int N,K;main(){cin>>N>>K;if(K==1){cout<<(mint(2).pow(N)-1).val()<<endl;return 0;}map<int,mint>mp,nxt;mp[K]=1;for(int i=0;i<N;i++){nxt.clear();long _A;cin>>_A;int A=gcdl(_A,K);for(const pair<int,mint>p:mp){int t=gcd(A,p.first);nxt[p.first/t]+=p.second;nxt[p.first]+=p.second;}mp.swap(nxt);}cout<<mp[1].val()<<endl;}