Cod sursa(job #42904)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 29 martie 2007 16:52:33
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream.h>

long long n, s;

int prim(long x,long y)
{
  while (x!=y)
    {
      if (x>y) x=x-y;
	else y-=x;
    }
  if (x==1) return 1;
  return 0;
}

void calcul()
{
  long i, j;
  ifstream in("fractii.in");
  in>>n;
  for (i=1; i<=n; i++)
    {for (j=1; j<=i; j++)
      if (i%2==0 && j%2==0);
	else	if (prim(i,j)) s+=2;
    }
  ofstream out("fractii.out");
  out<<s-1;
  in.close();
  out.close();
}

int main()
{
  calcul();
  return 0;
}