Cod sursa(job #173189)

Utilizator mariusake212Isac Marius-Sergiu mariusake212 Data 7 aprilie 2008 14:50:09
Problema Plus Scor 35
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.91 kb
 var  
       f:text;  
       a1,b1,a2,b2,a3,b3,s,st,i,j,y,k:longint;  
    begin  
         assign(f,'plus.in');reset(f);  
         read(f,s);  
        read(f,b1,a1);read(f,b2,a2); read(f,b3,a3);  
        close(f);  
         assign(f,'plus.out');rewrite(f);  
        k:=0;  
        if (a1<=0) and (a2<=0) and (a3=0)and (s>0) then begin write(f,0); close(f); exit; end;  
        if (a1>=0) and (a2>=0) and (a3>=0)and (s<0)   then  begin write(f,0); close(f); exit;   end;  
        for i:=0 to b1 do  
            for j:=0 to b2 do  
                for y:=0 to b3 do  
                 begin  
                 st:=i*a1+j*a2+y*a3;  
                 if st=s then
                                begin
                                k:=k+1;
                                if b3 <>0 then break;
                                end;
                 end;
      write(f,k);
      close(f);  end.