fork download
  1. #include <bits/stdc++.h>
  2. #define max_size 1000001
  3. #define ll long long int
  4. using namespace std;
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cout.tie(NULL);
  10. int t;
  11. cin>>t;
  12. while (t--)
  13. {
  14. ll n,max=0;
  15. cin>>n;
  16. ll a[max_size]={0},b[n];
  17. for(ll i=0;i<n;i++)
  18. {
  19. cin>>b[i];
  20. for(ll j=1;j<=sqrt(b[n]);j++)
  21. {
  22. if(b[i]%j==0)
  23. {
  24. if(b[i]/j==j)
  25. a[j]++;
  26. else
  27. {
  28. a[j]++;
  29. a[b[i]/j]++;
  30. }
  31. }
  32. }
  33. if(max<a[b[i]])
  34. max=a[b[i]];
  35. }
  36. cout<<max<<endl;
  37. }
  38. }
Success #stdin #stdout 0.66s 11248KB
stdin
1
7
8 1 28 4 2 6 7
stdout
7