/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 516.0 KiB
#2 Accepted 36ms 544.0 KiB
#3 Accepted 37ms 540.0 KiB
#4 Accepted 35ms 560.0 KiB
#5 Accepted 35ms 540.0 KiB
#6 Accepted 34ms 544.0 KiB
#7 Accepted 35ms 796.0 KiB
#8 Accepted 34ms 580.0 KiB
#9 Accepted 37ms 540.0 KiB
#10 Accepted 3ms 420.0 KiB
#11 Accepted 3ms 540.0 KiB
#12 Accepted 33ms 668.0 KiB
#13 Accepted 11ms 540.0 KiB

Code

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fast_io std::ios::sync_with_stdio(0);std::cin.tie(0)
#define lli long long int
#define flush fflush(stdout)
#define new_line printf("\n")
#define yn(a, b) printf("%s\n", (a) >= (b) ? "Yes":"No")
#define amodm(a, M) (((a)%M+M)%M)
// #define int lli

using pii = std::pair<int,int>;

const int MOD = 1000000007;
const int mxN = 200100;

int present[mxN];

signed main() {
    int testCases=1;
    // scanf("%d",&testCases);
    
    for (int TC = 1; TC <= testCases; TC++) {
        int n;
        scanf("%d",&n);
        for (int i = 0, v; i < n; i++) {
            scanf("%d",&v);
            present[v]++;
        }
        
        for (int k = 1; k <= n; k++) {
            int ans = 0;
            for (int v = 100000; v >= 1; v--) {
                int multiple = 1, possible = 0;
                while ((lli)multiple*v <= 100000) {
                    possible += present[multiple*v];
                    multiple++;
                }
                if (possible && possible+present[0] >= k) {
                    ans = v;
                    break;
                }
            }
            printf("%d ", ans);
        }
        
    }
    
    return 0;
}

/*

*/

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 15:28:37
Judged At
2025-01-02 15:28:37
Judged By
Score
100
Total Time
37ms
Peak Memory
796.0 KiB