/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 1.523 MiB
#2 Accepted 2ms 1.523 MiB
#3 Accepted 5ms 1.52 MiB
#4 Accepted 2ms 1.52 MiB
#5 Accepted 3ms 1.52 MiB
#6 Accepted 4ms 1.512 MiB
#7 Accepted 7ms 1.523 MiB
#8 Accepted 10ms 1.52 MiB
#9 Accepted 32ms 1.52 MiB
#10 Accepted 12ms 1.703 MiB
#11 Accepted 12ms 1.691 MiB
#12 Accepted 12ms 1.523 MiB
#13 Accepted 6ms 1.52 MiB

Code

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, N = 1e5 + 10, mx  = 0;
    cin >> n;
    vector<int> a(n + 1), vis(N), p(N), ans(N, 1);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        vis[a[i]]++;
        mx = max(mx, a[i]);
    }
    sort(a.begin(), a.end());
    for (int i = 2; i <= mx; i++){
        //if (p[i] != 1){
            int cnt = 0;
            for (int j = 1; j <= n; j++){
                //p[j] = 1;
                if (a[j] % i == 0) cnt++;
            }
            for (int k = 1; k <= cnt; k++){
                ans[k] = max(ans[k], i);
            }
        //}
    }
    if (mx == 0){
        for (int i = 1; i <= n; i++){
            cout << mx << ' ';
        }
        return 0;
    }
    if (mx == 1){
        for (int i = 1; i <= n; i++){
            cout << mx << ' ';
        }
        return 0;
    }
    for (int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 16:31:51
Judged At
2025-01-02 16:31:51
Judged By
Score
100
Total Time
32ms
Peak Memory
1.703 MiB