結果

問題 No.1036 Make One With GCD 2
ユーザー firiexpfiriexp
提出日時 2020-04-25 17:43:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,007 bytes
コンパイル時間 4,418 ms
コンパイル使用メモリ 159,912 KB
実行使用メモリ 15,984 KB
最終ジャッジ日時 2023-08-07 07:25:03
合計ジャッジ時間 16,051 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
7,208 KB
testcase_01 AC 110 ms
6,988 KB
testcase_02 AC 138 ms
7,024 KB
testcase_03 AC 26 ms
4,420 KB
testcase_04 AC 46 ms
5,620 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 49 ms
4,688 KB
testcase_08 AC 40 ms
4,396 KB
testcase_09 AC 308 ms
6,908 KB
testcase_10 AC 288 ms
6,588 KB
testcase_11 AC 315 ms
7,008 KB
testcase_12 AC 291 ms
6,588 KB
testcase_13 AC 460 ms
6,704 KB
testcase_14 AC 464 ms
6,604 KB
testcase_15 AC 436 ms
6,508 KB
testcase_16 AC 438 ms
6,736 KB
testcase_17 AC 452 ms
6,756 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 429 ms
6,520 KB
testcase_23 AC 316 ms
5,804 KB
testcase_24 AC 446 ms
6,796 KB
testcase_25 AC 408 ms
6,380 KB
testcase_26 AC 423 ms
6,612 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,388 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 TLE -
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;

ll gcd_(ll x, ll y){
    if(x < y) swap(x, y);
    while(y){
        x %= y;
        swap(x, y);
    }
    return x;
}

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;
        X[now].clear();
        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