結果

問題 No.1731 Product of Subsequence
ユーザー hiro71687khiro71687k
提出日時 2023-03-31 00:43:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 4,852 ms
コンパイル使用メモリ 272,140 KB
実行使用メモリ 169,424 KB
最終ジャッジ日時 2023-10-22 07:37:27
合計ジャッジ時間 17,490 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 958 ms
157,908 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 33 ms
8,580 KB
testcase_09 WA -
testcase_10 AC 1,106 ms
168,780 KB
testcase_11 AC 949 ms
146,016 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 16 ms
7,552 KB
testcase_14 AC 837 ms
128,636 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 907 ms
133,864 KB
testcase_19 AC 18 ms
7,560 KB
testcase_20 AC 730 ms
109,700 KB
testcase_21 AC 1,104 ms
169,424 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 15 ms
7,448 KB
testcase_25 AC 7 ms
5,216 KB
testcase_26 AC 167 ms
32,564 KB
testcase_27 AC 229 ms
41,868 KB
testcase_28 AC 491 ms
79,576 KB
testcase_29 AC 176 ms
34,436 KB
testcase_30 AC 911 ms
168,152 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 WA -
testcase_33 AC 4 ms
4,348 KB
testcase_34 AC 60 ms
16,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=999999999999999999;
ll gcd(ll a, ll b) {
	a = abs(a); b = abs(b);
	if (a < b)swap(a, b);
	while (b) {
	    ll r=a%b;
        a=b;
	    b=r;
	}
	return a;
}
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]=gcd(k,a[i]);
    }
    vector<map<ll,ll>>dp(n);
    dp[0][1]=1;
    ll x=gcd(k,a[0]);
    dp[0][x]+=1;
    for (ll i = 1; i < n; i++)
    {
        for(auto v:dp[i-1]){
            dp[i][v.first]+=v.second;
            dp[i][v.first]%=mod;
            ll z=v.first*a[i];
            z=gcd(k,z);
            dp[i][z]+=v.second;
            dp[i][z]%=mod;
        }
    }
    cout << dp[n-1][k] << endl;
}
0