luogu_1414 又是毕业季II

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,a[10010],t[1000010],dp[10010],maxn,cnt;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        t[x]++;
        maxn=max(maxn,x);
    }
    for(int i=1;i<=maxn;i++){
        cnt=0;
        for(int j=1;i*j<=maxn;j++)cnt+=t[i*j];
        for(int j=1;j<=cnt;j++)a[j]=max(a[j],i);
    }
    for(int i=1;i<=n;i++)printf("%d\n",a[i]);
    return 0;
}

  

posted @ 2017-10-07 17:16  wqtnb_tql_qwq_%%%  阅读(109)  评论(0编辑  收藏  举报