Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- ll nod(ll n) {
- vector<ll>v;
- if (n==1) return 1;
- for (int i=2; i*i<=n; i++) {
- if (n%i==0) v.push_back(0);
- while (n%i==0) {
- n/=i;
- v.back()++;
- }
- if (n==1) break;
- }
- if (n!=1) v.push_back(1);
- ll ans=1;
- for (auto i:v) ans*=(i+1);
- return ans;
- }
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- ll n;
- cin >> n;
- ll x=0;
- for (int i=0; i<n; i++) {
- ll v;
- cin >> v;
- x=gcd(v,x);
- }
- cout << nod(x);
- return 0;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment