lina_os

Untitled

May 10th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4.  
  5. using namespace std;
  6.  
  7. ll nod(ll n) {
  8.     vector<ll>v;
  9.     if (n==1) return 1;
  10.     for (int i=2; i*i<=n; i++) {
  11.         if (n%i==0) v.push_back(0);
  12.         while (n%i==0) {
  13.             n/=i;
  14.             v.back()++;
  15.         }
  16.         if (n==1) break;
  17.     }
  18.     if (n!=1) v.push_back(1);
  19.     ll ans=1;
  20.     for (auto i:v) ans*=(i+1);
  21.     return ans;
  22. }
  23.  
  24. int main() {
  25.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  26.     ll n;
  27.     cin >> n;
  28.     ll x=0;
  29.     for (int i=0; i<n; i++) {
  30.         ll v;
  31.         cin >> v;
  32.         x=gcd(v,x);
  33.     }
  34.     cout << nod(x);
  35.     return 0;
  36. }
  37.  
  38. /*
  39.  */
Advertisement
Add Comment
Please, Sign In to add comment