Lucian_Adrian

#496 Numarare4

Dec 4th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. short v[201];
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11. short n, i, a, b, c=0, r;
  12.  
  13. cin >> n;
  14.  
  15. for (i=1; i<=n; ++i) cin >> v[i];
  16.  
  17. for (i=1; i<n; ++i)
  18.  
  19. {
  20.  
  21. a=v[i]; b=v[n];
  22.  
  23. while (b!=0)
  24.  
  25. {
  26.  
  27. r=a%b; a=b; b=r;
  28.  
  29. }
  30.  
  31. if (a==1) ++c;
  32.  
  33. }
  34.  
  35. cout << c;
  36.  
  37. return 0;
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment