Lucian_Adrian

#498 NumararePIE

Dec 4th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n, x[205];
  6. cin >> n;
  7. for(int i = 0 ; i < n ; ++ i)
  8. cin >> x[i];
  9. int cnt = 0;
  10. for(int i = 0; i < n - 1 ; ++i)
  11. for(int j = i + 1 ; j < n ; ++ j)
  12. {
  13. int a = x[i], b = x[j] , r;
  14. if(b == 0)
  15. b = a;
  16. else
  17. while(a % b != 0)
  18. {
  19. r = a % b;
  20. a = b;
  21. b = r;
  22. }
  23. if(b==1)
  24. cnt ++;
  25.  
  26. }
  27. cout << cnt;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment