結果

問題 No.1036 Make One With GCD 2
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-03-30 15:56:02
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 671 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 159,816 KB
実行使用メモリ 30,520 KB
最終ジャッジ日時 2024-03-30 15:56:58
合計ジャッジ時間 52,772 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 1,685 ms
15,260 KB
testcase_02 AC 1,764 ms
15,260 KB
testcase_03 AC 33 ms
8,796 KB
testcase_04 AC 59 ms
13,932 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 436 ms
8,980 KB
testcase_08 AC 350 ms
8,628 KB
testcase_09 AC 1,573 ms
15,212 KB
testcase_10 AC 1,454 ms
14,932 KB
testcase_11 AC 1,605 ms
15,364 KB
testcase_12 AC 1,468 ms
14,996 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,970 ms
14,884 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 6 ms
6,676 KB
testcase_21 AC 6 ms
6,676 KB
testcase_22 AC 1,946 ms
14,924 KB
testcase_23 AC 1,385 ms
13,972 KB
testcase_24 TLE -
testcase_25 AC 1,831 ms
14,692 KB
testcase_26 AC 1,904 ms
14,804 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 1 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 1 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 2 ms
6,676 KB
testcase_38 AC 1,733 ms
15,260 KB
testcase_39 TLE -
testcase_40 AC 1,386 ms
13,972 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace atcoder;
using namespace std;
using ll = long long;
ll op(ll a, ll b) {return gcd(a, b);}
ll e() {return 0LL;}
int main() {
	int N;cin >> N;
	vector<ll> A(N + 1, 0);
	for (int i = 1;i <= N;i++) cin >> A[i];
	segtree<ll, op,  e> seg(A);
	ll ans = 0;
	for (int i = 1;i <= N;i++) {
		int ok = i;
		int ng = N  +1;
		if (A[i] == 1) {
			ans += N - i + 1;continue;
		}
		while (ng - ok > 1) {
			int m = (ok + ng) / 2;
			ll g = seg.prod(i, m + 1);
			if (g == 1) {
				ng = m;
			} else {
				ok = m;
			}
		}
		if (ok == i) {
			ans += N - i;
		} else {
			ans += N - ok;
		}
		
	}
	cout << ans << endl;
}
0