結果

問題 No.1036 Make One With GCD 2
ユーザー firiexpfiriexp
提出日時 2020-04-25 17:35:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 932 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 162,196 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-25 01:09:31
合計ジャッジ時間 8,360 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
12,928 KB
testcase_01 AC 144 ms
7,376 KB
testcase_02 AC 135 ms
7,200 KB
testcase_03 AC 23 ms
5,376 KB
testcase_04 AC 39 ms
6,016 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;



static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&k : v) scanf("%lld", &k);
    ll ans = 0;
    using M = gp_hash_table<ll, ll>;
    vector<M> X(2);
    for (int i = 0; i < n; ++i) {
        int now = i&1, nxt = now^1;
        for (auto &&k : X[now]) {
            k.second = 0;
        }
        for (auto &&j : X[nxt]) {
            X[now][gcd(j.first, v[i])] += j.second;
        }
        X[now][v[i]]++;
        ans += X[now][1];
    }
    cout << ans << "\n";
    return 0;
}
0