fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int gcd(int a,int b) {
  6.  
  7.  
  8. if (b==0) return a;
  9.  
  10.  
  11. return gcd(b,a%b);
  12. }
  13.  
  14. void solve() {
  15.  
  16.  
  17. int n; cin >> n;
  18.  
  19. int a[n];
  20. for (int i=0; i<n; i++) cin >> a[i];
  21.  
  22. int g=gcd(a[0],a[1]);
  23.  
  24. for (int i=2; i<n; i++) {
  25.  
  26. g=gcd(g,a[i]);
  27.  
  28. }
  29.  
  30. int count=0;
  31. for (int i=1; i*i<=g; i++) {
  32.  
  33. if (g%i==0) {
  34.  
  35. count++;
  36.  
  37. }
  38.  
  39. if (g%i!=i) count++;
  40.  
  41. }
  42.  
  43.  
  44.  
  45. cout << count << endl;
  46.  
  47.  
  48.  
  49.  
  50.  
  51. }
  52.  
  53. int main() {
  54.  
  55. // ios_base::sync_with_stdio(false);
  56. // cin.tie(NULL);
  57.  
  58. int t = 1;
  59. // cin >> t;
  60.  
  61.  
  62. while(t--) {
  63.  
  64. solve();
  65. }
  66.  
  67.  
  68. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
3 9 12 15 18
stdout
2