Pagini recente » Monitorul de evaluare | Cod sursa (job #3173755) | Cod sursa (job #2317) | Cod sursa (job #2224371) | Cod sursa (job #189947)
Cod sursa(job #189947)
#include<fstream.h>
#include<math.h>
ifstream fin("fractii.in");
ofstream fout("fractii.out");
long n,i,j,c,a[1000001],b[1000001];
long cmmdc(long x,long y)
{
int r;
do
{
r=x % y;
x=y;
y=r;
}
while(r);
return x;
}
int cauta(long x,long y)
{
long ok=0,t;
for(t=1;t<c;t++)
if(a[t]==x && b[t]==y) ok=1;
return ok;
}
/*
void afis()
{
for(i=1;i<=c;i++)
fout<<"( "<<a[i]<<" / "<<b[i]<<" ) ";
}
*/
int main()
{
fin>>n;
//c=2*n+1;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
if(cmmdc(i,j)==1)
if(cauta(i,j)==0)
{
c++;
a[c]=i;
b[c]=j;
// fout<<"( "<<i<<"/"<<j<<" ) ";
}
//afis();
fout<<"\n"<<2*c+1<<"\n";
return 0;
}