Advertisement
Tolyamba

Untitled

Jun 13th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. // CF_TR4_B
  2. #include <iostream>
  3. #include <stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. int gcd(int x, int y)
  8. {
  9.     if (x == 0) return y;
  10.     else return gcd(y%x, x);
  11. }
  12.  
  13. int main()
  14. {
  15.     int n;
  16.     //cin >> n;
  17.     scanf("%d", &n);
  18.     int mas[101];
  19.     for (int i = 0; i < n; i++)
  20.         scanf("%d", &mas[i]);
  21.  
  22.     int ans = 0;
  23.    
  24.     for (int i = 1; i < n; i++)
  25.         ans = gcd(mas[0], mas[i]);
  26.    
  27.     //cout << ans;
  28.     printf("%d", ans);
  29.     //system("pause");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement