結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 34 ms
8,248 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 18 ms
7,196 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 19 ms
7,204 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 20 ms
7,200 KB
testcase_25 AC 8 ms
4,860 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
    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