Advertisement
jbn6972

Untitled

Nov 9th, 2022
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. // Code Written by : John Nixon
  2. // Date: 09:11:2022  Time: 20:37:40
  3. // Copyrights are applicable
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. #define int long long int
  7. #define mod 1e9 + 7
  8. #define F first
  9. #define S second
  10. #define pb push_back
  11. #define si set<int>
  12. #define vi vector<int>
  13. #define pii pair<int, int>
  14. #define vpi vector<pii>
  15. #define vpp vector<pair<int, pii>>
  16. #define mii map<int, int>
  17. #define mpi map<pii, int>
  18. #define spi set<pii>
  19. #define endl "\n"
  20. #define sz(x) ((int)x.size())
  21. #define all(p) p.begin(), p.end()
  22. #define double long double
  23. #define que_max priority_queue<int>
  24. #define que_min priority_queue<int, vi, greater<int>>
  25. #define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
  26. #define print(a)          \
  27.     for (auto x : a)      \
  28.         cout << x << " "; \
  29.     cout << endl
  30. #define print1(a)    \
  31.     for (auto x : a) \
  32.     cout << x.F << " " << x.S << endl
  33. #define print2(a, x, y)         \
  34.     for (int i = x; i < y; i++) \
  35.         cout << a[i] << " ";    \
  36.     cout << endl
  37. inline int power(int a, int b)
  38. {
  39.     int x = 1;
  40.     while (b)
  41.     {
  42.         if (b & 1)
  43.             x *= a;
  44.         a *= a;
  45.         b >>= 1;
  46.     }
  47.     return x;
  48. }
  49.  
  50. template <typename Arg1>
  51. void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; }
  52. template <typename Arg1, typename... Args>
  53. void __f(const char *names, Arg1 &&arg1, Args &&...args)
  54. {
  55.     const char *comma = strchr(names + 1, ',');
  56.     cout.write(names, comma - names) << " : " << arg1 << " | ";
  57.     __f(comma + 1, args...);
  58. }
  59. const int N = 200005;
  60. int computeGCD(vi& a,int i){
  61.     if(i==sz(a)-1){
  62.         return a[i];
  63.     }
  64.     return __gcd(a[i],computeGCD(a,i+1));
  65. }
  66. void solve()
  67. {
  68.     int n;
  69.     cin>>n;
  70.     vi a(n);
  71.  
  72.     for (int i = 0; i < n; i++)
  73.     {
  74.         cin >> a[i];
  75.  
  76.     }
  77.     int gcd=computeGCD(a,0);
  78.     int ans=0;
  79.     for (int i = 0; i < n; i++)
  80.     {
  81.         if(a[i] == gcd){
  82.             ans++;
  83.         }
  84.     }
  85.     cout<<n-ans<<endl;
  86. }
  87. int32_t main()
  88. {
  89.     ios_base::sync_with_stdio(0);
  90.     cin.tie(0);
  91.     cout.tie(0);
  92. #ifndef ONLINE_JUDGE
  93.     freopen("input.txt", "r", stdin);
  94.     freopen("output.txt", "w", stdout);
  95. #endif
  96.     clock_t z = clock();
  97.     int t = 1;
  98.     cin >> t;
  99.     while (t--)
  100.         solve();
  101.     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement