Ankit_132

F

Jul 21st, 2023 (edited)
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.  
  12.     _test
  13.     {
  14.         int n;
  15.         cin>>n;
  16.  
  17.         vector<int> a(n);
  18.         for(auto &e: a)
  19.             cin>>e;
  20.  
  21.         map<int, int> cnt;
  22.  
  23.         for(auto e: a)
  24.             cnt[e]++;
  25.  
  26.         vector<int> vals(n+1);
  27.  
  28.         for(auto [a, b]: cnt)
  29.         {
  30.             for(int i=a; i<=n; i+=a)
  31.                 vals[i] += b;
  32.         }
  33.  
  34.         cout<<*max_element(vals.begin(), vals.end())<<"\n";
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment