Cod sursa(job #1197501)

Utilizator cojocarugabiReality cojocarugabi Data 12 iunie 2014 11:50:01
Problema Pascal Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.36 kb
var x,y:                      int64;
      t:                       text;
    i,j:                    longint;
    v,s:array[1..500000] of longint;
      a:                      int64;
      function corespunde(a:int64):boolean;
       var   i,j:                    longint;
             aux:array[1..500000] of longint;
        begin
         aux:=v;

         for i:=2 to (x+1) do
                aux[i]:=aux[i]-s[i];
    //     writeln('a',a);
  //       for i:=1 to (x+1) do write(s[i],' ');writeln;
         for i:=2 to 3 do
         if (aux[i]*i mod y)=0 then
             corespunde:=true else corespunde:=false;
        end;
          begin
           assign(t,'pascal.in');
           reset(t);
           readln(t,x,y);
           for i:=2 to (x+1) do begin
             a:=i;
             while (a>1) do begin
               for j:=2 to (a) do
               if a mod j=0 then begin
                 inc(v[j]);a:=a div j;
                 break;
               end;
             end;
           end;
           close(t);a:=0;
           for i:=2 to (x) do inc(s[i]);
           for i:=2 to (x) do begin
             inc(s[i]);
             dec(s[x-i+2]);
             if corespunde(i) then inc(a);
           end;
           assign(t,'pascal.out');
           rewrite(t);
           writeln(t,a);
           close(t);
          end.