Codeforces 757B — Bash's Big Day(简单数学)(易wa)

757B — Bash's Big Day

直接代码

/*
特例就是  *****a[i]全部为1时*****
ans   最小为 1

还有最开始我用的是  2,sqrt(max)  区间内的素数来判断   这样漏掉了一部分因子
官方是  每一个数  全部质因数分解  统计每个因子有多少数 最后for  ans=max(ans,factor[i])



*/
int n;
int a[maxn];
int vis[maxn];
int main()
{
    #ifdef local
    freopen("input2.txt","r",stdin);
    #endif // local
    int ans=1;
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>a[i];
    vis[a[i]]+=1;
    }
for(int i=2;i<=1e5;i++)
{int tem=0;
    for(int j=i;j<=1e5;j+=i){
        tem+=vis[j];
    }
ans=max(ans,tem);
}
cout<<ans<<en;
return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_40675883/article/details/89011038
今日推荐