about summary refs log tree commit diff
path: root/codechef/msv.cc
blob: 6206cffe35c906581f41a11d5bdccf9a14965dd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <algorithm>
#include <iostream>
#include <unordered_map>

using namespace std;

int
main()
{
  int t, n, i;
  long a;

  cin >> t;
  while (t--)
    {
      int star = 0;
      unordered_map<long, int> m;

      cin >> n;
      while (n--)
        {
          cin >> a;
          star = max (m[a], star);

          for (i = 1; i * i < a; ++i)
            if (a % i == 0)
              {
                m[i]++;
                m[a / i]++;
              }
          if (i * i == a)
            m[i]++;
        }

      cout << star << endl;
    }

  return 0;
}