結果

問題 No.1036 Make One With GCD 2
ユーザー pekempeypekempey
提出日時 2020-04-24 21:33:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,705 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 205,944 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-25 00:51:25
合計ジャッジ時間 12,694 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
7,296 KB
testcase_01 AC 180 ms
7,296 KB
testcase_02 AC 160 ms
7,168 KB
testcase_03 AC 20 ms
5,376 KB
testcase_04 AC 35 ms
5,888 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 56 ms
5,376 KB
testcase_08 AC 46 ms
5,376 KB
testcase_09 AC 196 ms
7,040 KB
testcase_10 AC 183 ms
6,784 KB
testcase_11 AC 196 ms
7,168 KB
testcase_12 AC 182 ms
6,912 KB
testcase_13 AC 291 ms
6,912 KB
testcase_14 AC 299 ms
7,040 KB
testcase_15 AC 279 ms
6,784 KB
testcase_16 AC 287 ms
6,784 KB
testcase_17 AC 289 ms
7,040 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 274 ms
6,656 KB
testcase_23 AC 211 ms
5,888 KB
testcase_24 AC 284 ms
6,912 KB
testcase_25 AC 260 ms
6,656 KB
testcase_26 AC 268 ms
6,656 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 1,705 ms
7,168 KB
testcase_39 AC 162 ms
7,296 KB
testcase_40 AC 205 ms
5,760 KB
testcase_41 AC 193 ms
7,168 KB
testcase_42 AC 191 ms
7,168 KB
testcase_43 AC 189 ms
7,168 KB
testcase_44 AC 188 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    map<ll, ll> dp;
    ll ans = 0;
    rep(i, N) {
        map<ll, ll> ep;
        for (auto [k, v] : dp) {
            ep[gcd(k, A[i])] += v;
        }
        ep[A[i]]++;
        dp = ep;
        ans += dp[1];
    }
    cout << ans << endl;
}
0