fork download
  1. #include<stdio.h>
  2. #define ll long long
  3. #include<math.h>
  4. int gcd(int a, int b){
  5. while(b > 0){
  6. int tmp = a % b;
  7. a = b;
  8. b = tmp;
  9. }
  10. return a;
  11. }
  12. int main(){
  13. int n;
  14. scanf("%d",&n);
  15. int a[n];
  16. for(int i = 0; i < n; i++){
  17. scanf("%d",&a[i]);
  18. }
  19. int cnt = 0;
  20. for(int i = 0; i < n; i++){
  21. for(int j = i+1 ; j < n; j++ ){
  22. if(gcd(a[i], a[j]) == 1){
  23. cnt++;
  24. }
  25. }
  26. }
  27. printf("%d", cnt);
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty