結果

問題 No.1731 Product of Subsequence
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-03 01:12:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,035 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 124,696 KB
実行使用メモリ 169,088 KB
最終ジャッジ日時 2023-08-28 07:15:16
合計ジャッジ時間 11,722 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 867 ms
157,544 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 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,380 KB
testcase_08 AC 29 ms
8,228 KB
testcase_09 WA -
testcase_10 AC 993 ms
168,424 KB
testcase_11 AC 862 ms
145,664 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 13 ms
7,160 KB
testcase_14 AC 755 ms
128,260 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 778 ms
133,588 KB
testcase_19 AC 15 ms
7,284 KB
testcase_20 AC 623 ms
109,344 KB
testcase_21 AC 1,013 ms
169,088 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 14 ms
7,132 KB
testcase_25 AC 6 ms
4,844 KB
testcase_26 AC 152 ms
32,180 KB
testcase_27 AC 209 ms
41,504 KB
testcase_28 AC 443 ms
79,212 KB
testcase_29 AC 165 ms
34,052 KB
testcase_30 AC 864 ms
167,820 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 WA -
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 57 ms
15,824 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;
using ll = long long;

vector<ll> factor;

void all_factor(ll n){
    for (ll i = 1; i*i <= n; i++){
        if (n % i == 0){
            factor.push_back(i);
            if (i*i != n) factor.push_back(n / i);
        }
    }
    sort(factor.begin(), factor.end());
}

const ll modc = 1e9+7;

int main(){

    ll N, K, g;
    cin >> N >> K;
    all_factor(K);
    vector<ll> A(N+1);
    vector<map<ll, ll>> dp(N+1);
    for (int i=1; i<=N; i++){
        cin >> A[i];
        A[i] = gcd(A[i], K);
    }
    dp[0][1] = 1;
    for (int i=1; i<=N; i++){
        for (auto [x, y] : dp[i-1]){
            dp[i][x] += y;
            dp[i][x] %= modc;
            g = gcd(A[i]*x, K);
            dp[i][g] += y;
            dp[i][g] %= modc;
        }
    }

    cout << dp[N][K] << endl;

    return 0;
}
0