Pagini recente » Cod sursa (job #3033453) | Cod sursa (job #1323500) | Cod sursa (job #2177384) | Cod sursa (job #985833) | Cod sursa (job #2428607)
#include <iostream>
#include <fstream>
using namespace std;
int M[100001];
bool primeIntreEle(int x,int y)
{
int i,j,r;
if(x>y)
{
i = x;
j = y;
}
else
{
i = y;
j = x;
}
r= i%j;
while(r!=0)
{
x = y;
y = r;
r = x%y;
}
if(y == 1)
return true;
else
return false;
}
bool isValidCombination(int x,int y)
{
if(x!=y && primeIntreEle(x,y))
return true;
}
int main()
{
ifstream fin("pairs.in");
ofstream fout("pairs.out");
int n,combs=0;
fin>>n;
for(int i = 0;i<n;i++)
fin>>M[i];
for(int i = 0;i<n;i++)
for(int j = i+1;j<n;j++)
if(isValidCombination(M[i],M[j]))
combs++;
fout<<combs;
return 0;
}