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

By |2017-04-07T22:10:20+00:00January 16th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#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; }