Cod sursa(job #42722)
Utilizator | Pandia Gheorghe Bluedrop_demon | Data | 29 martie 2007 14:22:28 |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 1.48 kb |
{
Problema fractii
}
Program fractii;
Type vector = array[0..1000000] of Longint;
Var n, i, j, l, k, aux : Longint;
c, c2 : vector;
nr : int64;
cod : boolean;
Begin
Assign( input, 'fractii.in' );
Reset( input );
Readln( n );
Close( input );
nr := n shl 1;
nr := nr-1;
For i := 2 to n do
if c[i] = 0 then
Begin
aux := i;
j := aux;
While j <= n do
Begin
j := j+aux;
c[j] := 1;
End;
End;
k := 0;
For i := 2 to n do
if c[i] = 0 then
Begin
k := k+1;
c2[k] := i;
End;
k := k+1;
c2[k] := n+1;
c2[0] := 0;
For i := 2 to n do
Begin
For j := 2 to i-1 do
Begin
l := 0;
cod := true;
While (c2[l] < j) do
Begin
l := l+1;
if ( i mod c2[l] = 0 ) and ( j mod c2[l] = 0 )
then
Begin
cod := false;
break;
End;
End;
if cod then nr := nr+2;
End;
End;
Assign( output, 'fractii.out' );
Rewrite( output );
Writeln( nr );
Close( output );
End.