結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー umezoumezo
提出日時 2021-11-05 23:42:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 196,608 KB
実行使用メモリ 11,984 KB
最終ジャッジ日時 2024-04-25 17:36:13
合計ジャッジ時間 8,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 298 ms
11,804 KB
testcase_01 AC 30 ms
11,052 KB
testcase_02 AC 29 ms
11,100 KB
testcase_03 AC 30 ms
11,200 KB
testcase_04 AC 30 ms
11,096 KB
testcase_05 AC 31 ms
11,056 KB
testcase_06 AC 30 ms
11,024 KB
testcase_07 AC 30 ms
10,988 KB
testcase_08 AC 30 ms
11,100 KB
testcase_09 AC 30 ms
11,028 KB
testcase_10 AC 31 ms
10,988 KB
testcase_11 AC 30 ms
11,148 KB
testcase_12 AC 30 ms
11,036 KB
testcase_13 AC 295 ms
11,868 KB
testcase_14 AC 297 ms
11,984 KB
testcase_15 AC 308 ms
11,752 KB
testcase_16 AC 302 ms
11,792 KB
testcase_17 AC 297 ms
11,896 KB
testcase_18 AC 296 ms
11,860 KB
testcase_19 AC 303 ms
11,868 KB
testcase_20 AC 296 ms
11,924 KB
testcase_21 AC 294 ms
11,940 KB
testcase_22 AC 301 ms
11,800 KB
testcase_23 AC 291 ms
11,940 KB
testcase_24 AC 292 ms
11,920 KB
testcase_25 AC 293 ms
11,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<int> A(1001001),B(1001001);
  rep(i,n){
    int a;
    cin>>a;
    A[a]++;
  }
  B[1]=n;
  for(int i=2;i<=1000000;i++){
    for(int j=i;j<=1000000;j+=i){
      B[i]+=A[j];
    }
  }
  vector<int> C(n+1);
  int now=0;
  int r=n-1;
  for(int i=1000000;i>0;i--){
    if(B[i]>now){
      while(n-B[i]<=r){
        C[r]=i;
        r--;
      }
      now=B[i];
    }
  }
  rep(i,n) cout<<C[i]<<endl;
  
    
  return 0;
}
0