結果

問題 No.1036 Make One With GCD 2
コンテスト
ユーザー rin204
提出日時 2022-07-09 15:39:27
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,442 ms
コンパイル使用メモリ 214,352 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2026-06-26 14:40:56
合計ジャッジ時間 8,719 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

using S = int;
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<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    segtree<S, op, e> seg(A);
    long long ans = 0;
    for(int r = 1; r <= n; r++){
        int l = seg.min_left(r, f);
        ans += l;
    }
    cout << ans << "\n";
}

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