結果

問題 No.2756 GCD Teleporter
ユーザー cho435cho435
提出日時 2024-05-11 17:10:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 4,910 ms
コンパイル使用メモリ 274,356 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-05-11 17:10:55
合計ジャッジ時間 9,700 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 12 ms
6,944 KB
testcase_05 AC 46 ms
6,944 KB
testcase_06 AC 129 ms
8,552 KB
testcase_07 AC 104 ms
7,552 KB
testcase_08 AC 93 ms
7,296 KB
testcase_09 AC 83 ms
6,944 KB
testcase_10 AC 135 ms
8,012 KB
testcase_11 AC 153 ms
9,032 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 248 ms
7,780 KB
testcase_21 AC 95 ms
6,944 KB
testcase_22 AC 159 ms
7,808 KB
testcase_23 AC 27 ms
6,940 KB
testcase_24 AC 168 ms
6,940 KB
testcase_25 AC 186 ms
7,032 KB
testcase_26 AC 172 ms
7,636 KB
testcase_27 AC 156 ms
7,944 KB
testcase_28 AC 91 ms
6,940 KB
testcase_29 AC 122 ms
7,168 KB
testcase_30 AC 163 ms
8,192 KB
testcase_31 AC 67 ms
6,940 KB
testcase_32 AC 301 ms
6,944 KB
testcase_33 AC 121 ms
6,940 KB
testcase_34 AC 22 ms
6,940 KB
testcase_35 AC 145 ms
6,940 KB
testcase_36 AC 110 ms
6,944 KB
testcase_37 WA -
testcase_38 AC 100 ms
7,272 KB
testcase_39 AC 92 ms
9,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

void chmin(int &a,int b){
	if(a>b) a=b;
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a.at(i);
	map<int,vector<int>> mp;
	rep(i,n){
		int tmp=a.at(i);
		for(int j=2;j*j<=tmp;j++){
			if(tmp%j==0){
				mp[j].push_back(i);
				while(tmp%j==0) tmp/=j;
			}
		}
		if(tmp>1) mp[tmp].push_back(i);
	}
	atcoder::dsu uf(n);
	for(auto&[x,v]:mp){
		for(auto&y:v){
			uf.merge(v.at(0),y);
		}
	}
	vector<int> sc(n,1e9);
	for(auto&[x,v]:mp){
		for(auto&y:v){
			chmin(sc.at(uf.leader(y)),x);
		}
	}
	int mn=1e9;
	set<int> st;
	rep(i,n){
		st.insert(uf.leader(i));
		chmin(mn,sc.at(uf.leader(i)));
	}
	cout<<(ll)mn*(st.size()-1)<<endl;
}
0