fork download
  1. //pb4f4//
  2. #include <iostream>
  3. using namespace std;
  4. int cmmdc(int a, int b)
  5. {
  6. while (b!=0)
  7. {
  8. int r;
  9. r=a%b;
  10. a=b;
  11. b=r;
  12. }
  13. return a;
  14. }
  15.  
  16. int perechi(int A[], int n)
  17. {
  18. int rez;
  19. rez=0;
  20. for (int i=0;i<n-1;i++)
  21. for (int j=i+1;j<=n-1;j++)
  22. if (cmmdc(A[i],A[j])==1)
  23. rez++;
  24. return rez;
  25. }
  26.  
  27. int n,A[1001];
  28.  
  29. int main()
  30. {
  31. cin>>n;
  32. for (int i=0;i<n;i++)
  33. cin>>A[i];
  34. cout<<perechi(A,n);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5452KB
stdin
Standard input is empty
stdout
Standard output is empty