Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<int> a(n);
- for(auto &e: a)
- cin>>e;
- map<int, int> cnt;
- for(auto e: a)
- cnt[e]++;
- vector<int> vals(n+1);
- for(auto [a, b]: cnt)
- {
- for(int i=a; i<=n; i+=a)
- vals[i] += b;
- }
- cout<<*max_element(vals.begin(), vals.end())<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment