結果

問題 No.1731 Product of Subsequence
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 15:07:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,028 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 121,212 KB
実行使用メモリ 169,120 KB
最終ジャッジ日時 2023-08-29 22:12:16
合計ジャッジ時間 11,851 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 906 ms
157,532 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 31 ms
8,200 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 1,025 ms
168,724 KB
testcase_11 AC 894 ms
145,700 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 13 ms
7,164 KB
testcase_14 AC 781 ms
128,268 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 802 ms
133,532 KB
testcase_19 AC 16 ms
7,180 KB
testcase_20 AC 645 ms
109,328 KB
testcase_21 AC 1,028 ms
169,120 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 14 ms
7,096 KB
testcase_25 AC 6 ms
4,868 KB
testcase_26 AC 155 ms
32,380 KB
testcase_27 AC 213 ms
41,628 KB
testcase_28 AC 456 ms
79,276 KB
testcase_29 AC 169 ms
34,104 KB
testcase_30 AC 912 ms
167,980 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 57 ms
15,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

const long long modc = 1e9+7;

int main(){

    long long N, K, X, g;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    vector<map<long long, long long>> dp(N+1);
    dp[0][1] = 1;

    for (int i=1; i<=N; i++){
        X = gcd(K, A[i-1]);
        for (auto &[a, b] : dp[i-1]){
            dp[i][a] += b;
            dp[i][a] %= modc;

            g = gcd(X*a, K);
            dp[i][g] += b;
            dp[i][g] %= modc;
        }
    }

    cout << dp[N][K] - (K == 1) << endl;

    return 0;
}
0