/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 588.0 KiB

Code

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
//#define int long long 
#define ll long long
#define ull unsigned long long
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define max_ele(v) *max_element(v.begin(), v.end())
#define min_ele(v) *min_element(v.begin(), v.end())
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v) reverse(v.begin(), v.end())
#define REV_SORT(v) sort((v).begin(), (v).end(), greater<>())
#define all(v) v.begin(), v.end()
#define vint vector<int>
#define u_set unordered_set
#define u_map unordered_map
#define setbit(x) __builtin_popcount(x)
#define lead_zero(x) __builtin_clz(x) 
#define trail_zero(x) __builtin_ctz(x) 
#define coutall(v) for(auto &&it : v) cout << it <<" "
#define coutnl(v) for(auto &&it : v) cout << it <<'\n'
#define cinall(v) for(auto &&it : v) cin >> it
#define cin2d(v) for(auto &&row : v) for(auto &&element : row) cin >> element;
#define cout2d(v) for (const auto& row : v) { for (const auto& element : row) cout << element << ' '; cout << '\n';}
#define nl cout << '\n';
using namespace std;
int cerrr = 1;
#define err cerr << "Thats GFG! " << cerrr++ << '\n'
const ll Inf = 0x3fffffffffffffff;
const int mod = 0x3b9aca07;

void debug_mode(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

void solve();
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    //debug_mode();
    int TestCase = 1;
    // cin >> TestCase; 
    int case_no = 1;
    while (TestCase--){
        // cout << "Case " << case_no++ << ": ";
        solve();
        // cout << '\n';
    }
    return 0;
}

void solve() {
    int n; cin >> n;
    vint a(n); cinall(a);
    int mx = max_ele(a);
    u_set<int> s;
    vint divs(mx + 1);
    for(int &x : a) {//6, 12, 15, 20, 6, 12
        if(s.find(x) != s.end()) continue;
        s.insert(x);
        for(int i = 1; i * i <= x; i++) {
            if(x % i == 0) {
                divs[i]++;
                divs[x / i] += (i != (x / i));
            }
        }
    }
    vint res(n + 1);
    for(int i = mx; i >= 1; i--) {
        for(int j = 1; j <= min(divs[i], n); j++) res[j] = max(res[j], i);
    }
    for(int i = 1; i <= n; i++) cout << res[i] << ' ';
}

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:59:42
Judged At
2025-01-02 16:59:42
Judged By
Score
0
Total Time
1ms
Peak Memory
588.0 KiB