/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 54ms 10.578 MiB
#2 Accepted 55ms 10.5 MiB
#3 Accepted 55ms 10.66 MiB
#4 Accepted 76ms 10.527 MiB
#5 Accepted 63ms 10.547 MiB
#6 Accepted 76ms 10.484 MiB
#7 Accepted 54ms 10.52 MiB
#8 Accepted 58ms 10.645 MiB
#9 Accepted 59ms 10.648 MiB
#10 Accepted 55ms 10.652 MiB
#11 Accepted 75ms 10.586 MiB
#12 Accepted 55ms 10.52 MiB
#13 Accepted 58ms 10.52 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
const int sz = 1e5 + 5 ;
vector < int > divisor[sz] ;
void preCaldivisor() {
    for (int i = 1; i <= 1e5; ++i) {
        for (int j = i; j <= 1e5 ; j += i) {
            divisor[j].pb(i);
        }
    }
}
void solve()
{
   map < int , int > freq ;
   int n , a; cin >> n ;
   int res[n + 5];
   set < int > st ;
   for(int i = 1 ; i <= n ; i++) res[i] = 1 ;
   for(int i = 1 ; i <= n ; i++){
    cin >> a ;
    if(!a) freq[a]++ ;
    for(auto it : divisor[a]) freq[it]++ , st.insert(it) ;
   }
   for(auto it : st){
    for(int i = 1 ; i <= freq[it] + freq[0] ; i++) res[i] = max(res[i] , it) ;
   }
   for(int i = 1 ; i <= n ; i++) cout << res[i] << " " ;
   cout << endl ;
}
int main()
{
     __Heart__
     preCaldivisor() ;
     int t ; t = 1 ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-19 00:29:12
Judged At
2024-12-19 00:29:12
Judged By
Score
100
Total Time
76ms
Peak Memory
10.66 MiB