/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 55ms 10.52 MiB
#2 Wrong Answer 55ms 10.562 MiB
#3 Wrong Answer 60ms 10.648 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];
   for(int i = 1 ; i <= n ; i++) res[i] = 1 ;
   for(int i = 1 ; i <= n ; i++){
    cin >> a ;
    for(auto it : divisor[a]){
        freq[it]++ ;
        for(int j = 1 ; j <= freq[it] ; j++){
            res[j] = max(res[j], 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:12:18
Judged At
2024-12-19 00:12:18
Judged By
Score
0
Total Time
60ms
Peak Memory
10.648 MiB