結果
問題 | No.1036 Make One With GCD 2 |
ユーザー |
![]() |
提出日時 | 2024-08-31 09:10:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 715 bytes |
コンパイル時間 | 6,090 ms |
コンパイル使用メモリ | 310,088 KB |
実行使用メモリ | 15,532 KB |
最終ジャッジ日時 | 2024-08-31 09:11:54 |
合計ジャッジ時間 | 59,564 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 34 TLE * 7 |
ソースコード
#include <atcoder/all>#include <bits/stdc++.h>#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)using namespace atcoder;using namespace std;typedef long long ll;ll op(ll a, ll b) { return gcd(a, b); }ll e() { return 0; }int main() {int n;cin >> n;vector<ll> a(n);rep(i, 0, n) cin >> a[i];segtree<ll, op, e> st(a);ll ans = 0;for (int i = 0; i < n; i++) {if (st.prod(i, n) != 1)break;int l = i, r = n;while (r - l > 1) {int m = (l + r) / 2;if (st.prod(i, m) == 1)r = m;elsel = m;}ans += n - r + 1;}cout << ans << endl;}