CodeCraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) 757B — Bash's Big Day Solution
Problem Link: https://codeforces.com/contest/757/problem/B
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,i,j,ans=1,mx,cnt=0;
map<ll,ll>mp;
cin>>n;
ll a[n];
for(i=0; i<n; i++)
{
cin>>a[i];
mp[a[i]]++;
}
for(i=2; i<=1e5; i++)
{
cnt=0;
for(j=i; j<=1e5; j+=i)
{
if(mp[j])
cnt+=mp[j];
}
ans=max(ans,cnt);
}
cout<<ans<<endl;
}
No comments