forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSV.cpp
68 lines (64 loc) · 962 Bytes
/
MSV.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
unordered_map<int,int> mp;
void factor(int x)
{
for(int i=1;i<=sqrt(x);i++)
{
if( x%i == 0)
{
if( x/i == i )
mp[i]++;
else
{
mp[i]++;
mp[x/i]++;
}
}
}
}
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n ;
int a[n];
for(int i=0;i<n;i++)
cin >> a[i];
int star[n];
star[0] = 0;
for(int i=0;i<n;i++)
{
if( mp.find(a[i])!=mp.end() )
star[i] = mp[a[i]];
else
star[i] = 0;
factor(a[i]);
// cout << a[i] << ":-> " << endl;
// for(auto it=mp.begin();it!=mp.end();it++)
// cout << it->first << ": " << it->second << endl;
// cout << endl;
}
// cout << "star values:-> ";
// for(int i=0;i<n;i++)
// {
// cout << star[i] << " ";
// }
int ind;
int M=0;
for(int i=0;i<n;i++)
{
if(star[i] > M)
{
M = star[i];
ind = i;
}
}
cout << M << endl;
mp.clear();
}
}