結果

問題 No.1036 Make One With GCD 2
ユーザー 👑 rin204rin204
提出日時 2022-07-09 15:50:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 869 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 201,820 KB
実行使用メモリ 15,312 KB
最終ジャッジ日時 2023-08-29 23:11:41
合計ジャッジ時間 16,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 458 ms
15,124 KB
testcase_01 AC 91 ms
15,260 KB
testcase_02 AC 203 ms
15,132 KB
testcase_03 AC 20 ms
8,672 KB
testcase_04 AC 33 ms
13,808 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 36 ms
8,736 KB
testcase_08 AC 30 ms
8,528 KB
testcase_09 AC 216 ms
15,224 KB
testcase_10 AC 202 ms
14,664 KB
testcase_11 AC 220 ms
15,188 KB
testcase_12 AC 204 ms
14,988 KB
testcase_13 AC 362 ms
14,988 KB
testcase_14 AC 366 ms
14,996 KB
testcase_15 AC 344 ms
14,968 KB
testcase_16 AC 346 ms
14,652 KB
testcase_17 AC 357 ms
14,848 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 339 ms
14,724 KB
testcase_23 AC 253 ms
13,916 KB
testcase_24 AC 353 ms
14,920 KB
testcase_25 AC 322 ms
14,700 KB
testcase_26 AC 333 ms
14,588 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 291 ms
15,240 KB
testcase_39 AC 869 ms
15,260 KB
testcase_40 AC 251 ms
13,860 KB
testcase_41 AC 641 ms
15,312 KB
testcase_42 AC 627 ms
15,244 KB
testcase_43 AC 608 ms
15,160 KB
testcase_44 AC 660 ms
15,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/segtree>
using namespace std;
using namespace atcoder;

using S = long long;
S op(S x, S y){
    if(x > y) swap(x, y);
    if(x == 0) return y;
    return op(y % x, x);
}

S e(){ return 0; }

bool f(S x){
    return x != 1;
}

void solve(){
    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    segtree<S, op, e> seg(A);
    long long ans = 0;
    int l = 0;
    for(int r = 1; r <= n; r++){
        while(l < r){
            auto x = seg.prod(l, r);
            if(x != 1) break;
            l++;
        }
        ans += l;
    }
    cout << ans << "\n";
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) solve();
}
0