Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (B) Bash’s Big Day Solution in C/C++

#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int i, temp, max=1, freq[100001]={0}, ans=1, j;
	for(i=0;i<n;i++){
		scanf("%d",&temp);
		freq[temp]++;
		if(temp>max){
			max=temp;
		}
	}
	for(i=2; i<=max; ++i){
		temp=0;
		for(j=i; j<=max; j+=i){
			temp+=freq[j];
		}
		if(temp>ans) ans=temp;
	}
	printf("%d",ans);
	return 0;
}
(Visited 109 times, 1 visits today)

About the Author:

Leave A Comment