Saturday 14 January 2017

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)/B. Bash's Big Day

Problem Link: http://codeforces.com/contest/757/problem/B
Code:
#include<bits/stdc++.h>
using namespace std;
const long long N=100009;
long long ar[N];
int main()
{

    long long i,n,c,x,ans,j;
//for(i=0;i<10;i++)
  //  cout<<ar[i]<<endl;
    while(cin>>n)
    {
        for(i=0; i<n; i++)
            {
                cin>>x;
                ar[x]++;
            }
            ans=1;
            for(i=2;i<=N;i++)
            {
                c=0;
                for(j=i;j<=N;j+=i)
                    c+=ar[j];
                    ans=max(ans,c);
            }
            cout<<ans<<endl;


    }
    return 0;
}

No comments:

Post a Comment