結果
| 問題 | 
                            No.2756 GCD Teleporter
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-05-10 23:13:14 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,924 bytes | 
| コンパイル時間 | 5,663 ms | 
| コンパイル使用メモリ | 320,088 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-12-20 07:28:14 | 
| 合計ジャッジ時間 | 8,696 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 4 WA * 32 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
//*/
#include <atcoder/all>
using namespace atcoder;
//*/
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dbgv(x); for(auto now : x) cout << now << " "; cout << endl;
//using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
//*/
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
random_device rnd;
mt19937 rng(rnd());
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if(n/i != i) ret.push_back(n/i);
        }
    }
    sort(ret.begin(),ret.end());
    return ret;
}
struct UnionFind {
  vector<int> par;
  UnionFind(int n=0): par(n,-1) {}
  int find(int x) {
    if(par[x] < 0) return x;
    return par[x] = find(par[x]);
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x==y) return false;
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) {return find(x) == find(y);}
  int size(int x) {return -par[find(x)];}
};
void solve(){
  int n; cin >> n;
  vint a(n); rep(i,n) cin >> a[i];
  auto v = divisor(a[0]);
  reverse(ALL(v));
  v.pop_back();
  map<int,int> mp;
  int cnt = n;
  for(ll x : v) mp[x] = ++cnt;
  ll sz = n+1+v.size();
  UnionFind dsu(sz);
  rep(i,n){
    for(ll x : v)if(a[i]%x==0) dsu.unite(i,mp[x]);
  }
  dsu.unite(n,0);
  ll c = sz-dsu.size(0);
  cout << v.back()*c << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1; //cin >> t;
  rep(testcases,t) solve();
}