/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 772.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 332.0 KiB
#5 Accepted 1ms 328.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 516.0 KiB
#8 Accepted 1ms 492.0 KiB
#9 Accepted 1ms 540.0 KiB
#10 Accepted 1ms 540.0 KiB
#11 Accepted 2ms 576.0 KiB
#12 Accepted 1ms 768.0 KiB
#13 Accepted 2ms 572.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set1 = tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update>;
#define op()                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define PI 2.0 * acos(0.0)
#define Dpos(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 1;

void solve()
{
    ll n, i, num, m, zero = 0;
    cin >> n;
    m = n;
    map<ll, ll> m1;
    while (n--)
    {
        cin >> num;
        ll temp = sqrt(num);
        for (i = 1; i <= temp; i++)
        {
            if (num % i == 0)
            {
                m1[i]++;
                if (num / i != i)
                    m1[num / i]++;
            }
        }
        if (num == 0)
            zero++;
    }

    for (i = 1; i <= m; i++)
    {
        for (auto it = m1.rbegin(); it != m1.rend(); it++)
        {
            if (it->second + zero >= i)
            {
                cout << it->first << ' ';
                break;
            }
        }
    }
    cout << endl;
}
int main()
{
    op() int tc = 1;
    // cin >> tc;

    for (int t = 1; t <= tc; t++)
    {
        // cout << "Case " << t << ": ";
        solve();
    }
}

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:34:56
Judged At
2025-01-02 15:34:56
Judged By
Score
100
Total Time
2ms
Peak Memory
772.0 KiB