Cod sursa(job #39457)

Utilizator silvia_the_bestSilvia Pripoae silvia_the_best Data 26 martie 2007 19:11:48
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.05 kb
var n,i,j,k:longint;
    f,g:text;
    v:array[1..10000,1..2] of integer;
function ireductibil(x,y:longint):boolean;
         var a,i:longint;
         label 1;
         begin
              if (x=1) and (y=1) then begin
                 ireductibil:=true;
                 goto 1;
              end;
              if x>y then a:=x
              else if y>x then a:=y
              else if x=y then a:=x;
              for i:=2 to a do if (x mod i=0) and (y mod i=0) then begin
                  ireductibil:=false;
                  goto 1;
              end;
              ireductibil:=true;
         1:end;
begin
     k:=0;
     assign(f,'fractii.in');
     reset(f);
     readln(f,n);
     close(f);
     for i:=1 to n do
         for j:=1 to n do begin
             k:=k+1;
             v[k,1]:=i;
             v[k,2]:=j;
         end;
     j:=0;
     for i:=1 to k do begin
         if ireductibil(v[i,1],v[i,2])=true then j:=j+1;
     end;
     assign(g,'fractii.out');
     rewrite(g);
     writeln(g,j);
     close(g);
end.