fork download
  1. /*
  2. -> Don't stop when you're tired, stop when you're done.
  3. -> From the river to the sea, Palestine will be free.
  4. --> @author: MIDORIYA_
  5. */
  6. //*==============================================================
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. typedef long long ll;
  10. typedef double db;
  11. typedef long double ld;
  12. typedef pair<int, int> pii;
  13. typedef pair<ll, ll> pll;
  14. typedef vector<int> vi;
  15. typedef vector<ll> vll;
  16. typedef vector<db> vd;
  17. typedef vector<ld> vld;
  18. typedef vector<bool> vb;
  19. typedef vector<vector<ll>> vvl;
  20. typedef vector<vector<int>> vvi;
  21. typedef vector<pii> vii;
  22. typedef set<int> si;
  23. typedef set<ll> sl;
  24. typedef multiset<int> msi;
  25. typedef multiset<ll> msl;
  26. #define pb push_back
  27. #define pf push_front
  28. #define popb pop_back
  29. #define popf pop_front
  30. #define fi first
  31. #define se second
  32. #define all(x) x.begin(), x.end()
  33. #define rall(x) x.rbegin(), x.rend()
  34. #define endl "\n"
  35. const int MOD = 998244353, mod = 1e9 + 7, maxA = 1e5 + 5;
  36. #define time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs";
  37. //*===================>>>FastIO - FileIO<<<=========
  38. void fastIO()
  39. {
  40. ios_base::sync_with_stdio(false);
  41. cin.tie(nullptr);
  42. cout.tie(nullptr);
  43. }
  44. void fileIO()
  45. {
  46. #ifndef ONLINE_JUDGE
  47. freopen("in.txt", "r", stdin);
  48. freopen("out.txt", "w", stdout);
  49. #endif
  50. }
  51. //*===================>>>ONE-FOR-ALL<<<=============
  52. ll GCD(ll a, ll b) {
  53. return (b == 0 ? a : GCD(b, a % b));
  54. }
  55.  
  56. ll GCD_Vect(vector<ll> &v) {
  57. ll ans = v[0];
  58. for (int i = 1; i < v.size(); i++)
  59. ans = GCD(ans, v[i]);
  60. return ans;
  61. }
  62.  
  63. vector<ll> getDivisors(ll n) {
  64. vector<ll> divisors;
  65. for (int i = 1; i * i <= n; i++)
  66. if (n % i == 0)
  67. divisors.push_back(i), divisors.push_back(n / i);
  68. if (sqrt(n) == int(sqrt(n)))
  69. divisors.push_back(sqrt(n));
  70. return divisors;
  71. }
  72.  
  73. void OneForAll()
  74. {
  75.  
  76. int n;
  77. cin >> n;
  78. vector<ll> v(n);
  79. for (int i = 0; i < n; i++)
  80. cin >> v[i];
  81. ll gcd = GCD_Vect(v);
  82. ll ans = 0;
  83. vector<ll> divisors = getDivisors(gcd);
  84. ans = divisors.size();
  85. cout << ans << endl;
  86. }
  87.  
  88. int main()
  89. {
  90. fastIO();
  91. // fileIO();
  92.  
  93. ll tc = 1, t = 1;
  94. // cin >> t;
  95. while (t--)
  96. {
  97. // cout << "Case " << tc++ << ": ";
  98. OneForAll();
  99. }
  100. time;
  101. return 0;
  102. }
Success #stdin #stdout #stderr 0.01s 5320KB
stdin
Standard input is empty
stdout
1
stderr
Time Taken: 0.006577 Secs