結果

問題 No.3717 GCD LCM GCD
コンテスト
ユーザー kukone
提出日時 2026-09-18 21:54:34
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,029 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,031 ms
コンパイル使用メモリ 375,268 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2026-09-18 21:54:50
合計ジャッジ時間 6,544 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using P=pair<ll,ll>;
typedef atcoder::modint mint;
ll inf=9e18;
template<typename T, int s, int i = 0>
auto vec(const ll (&sizes)[s], const T& init = T()){
  if constexpr(i < s) return vector(sizes[i], vec<T, s, i+1>(sizes, init));
  else return init;
}


vector<ll> w;
void dev(ll n){
  ll i=1;
  while(i*i<=n){
    if(n%i==0){
      w[i]++;
      if(i*i!=n) w[n/i]++;
    }
    i++;
  }
}

int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  if(k==1){
    ll x;
    ans=1;
    for(ll i=0;i<n;i++){
      cin>>x;
      ans=lcm(ans,x);
    }
    cout<<ans<<"\n";
    return 0;
  }
  auto v=vec<ll>({n},0);
  w=vector<ll>(1e6+5,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
    dev(v[i]);
  }
  // for(ll i=1;i<=100;i++){
  //   cout<<w[i]<<" ";
  // }
  // cout<<"\n";
  for(ll i=1;i<=1e6;i++){
    if(w[i]>=(n-1)/k+2){
      ans=i;
    }
  }
  cout<<ans<<"\n";
}
0