結果
問題 |
No.1730 GCD on Blackboard in yukicoder
|
ユーザー |
![]() |
提出日時 | 2021-11-05 23:42:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 283 ms / 2,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 2,993 ms |
コンパイル使用メモリ | 193,428 KB |
最終ジャッジ日時 | 2025-01-25 13:56:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
#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; }