Nombre Password [ Regístrate ]

Primolandia (OIE 6 - 2002) - Código en Pascal
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 16384,0,655360}
{Programed By FR 12/02/2006}
{********************************TIPOS***************************************}
type NuevaNumeracion = record
                          nprimo : longint;
                          expt   : longint;
                       end;

{******************************VARIALBLES************************************}
var
    fs : text;
    dividendo,divisor : array[1..4000]of NuevaNumeracion;
    i,j : 0..4000;

{***********************PROCEDIMIENTOS Y FUNCIONES***************************}
procedure Print(c:char);
var aux,aux1 : 0..4000;
begin
   aux1:=0;

   if c='s' then begin
       for aux:=1 to i do begin
          if dividendo[aux].expt=0 then begin write(fs,''); inc(aux1) end else
              write(fs,dividendo[aux].nprimo,' ',dividendo[aux].expt,' ');
       end;

       if aux1=i then writeln(fs,1);

       writeln(fs);
   end else

   writeln(fs,'NO DIVISIBLE');
end;
{----------------------------------------------------------------------------}
procedure SolucionaEstePar;
var auxi{dividendo},auxj{divisor},b : 0..4000;
begin
    b:=1;

    for auxi:=1 to i do begin
        for auxj:=b to j do begin
            if divisor[auxj].nprimo>dividendo[auxi].nprimo then begin
                print('n');
                exit
            end;

            if divisor[auxj].nprimo=dividendo[auxi].nprimo then begin
                if divisor[auxj].expt>dividendo[auxi].expt then begin
                    print('n');
                    exit
                end;{if}

                dividendo[auxi].expt:=dividendo[auxi].expt-divisor[auxj].expt;
                b:=auxj+1;
                break
            end;{if}

            if dividendo[auxi+1].nprimo<divisor[auxj].nprimo then begin
                print('n');
                exit
            end;
        end;{bucle auxj}
    end;{bucle auxi}

    print('s');
end;{procedure}
{----------------------------------------------------------------------------}
procedure ReadData;
var fe : text;
begin         {PRIM.RES}
    assign(fe,'PRIM.DAT');reset(fe);

    while not eof(fe) do begin
        i:=0;

        while not eoln(fe) do begin
            inc(i);
            read(fe,dividendo[i].nprimo);
            read(fe,dividendo[i].expt);
        end;

        readln(fe);

        j:=0;
        while not eoln(fe) do begin
            inc(j);
            read(fe,divisor[j].nprimo);
            read(fe,divisor[j].expt);
        end;

        readln(fe);

        SolucionaEstePar;
    end;

    close(fe);
end;

{****************************PROGRAMA PRINCIPAL******************************}
begin
    assign(fs,'PRIM.RES');rewrite(fs);

    ReadData; {PRIM.DAT}

    close(fs);
end.


© (2001-2008) ALGORITMIA.NET - Política de privacidad