Cod sursa(job #115530)

Utilizator meciprymecipry mecipry Data 16 decembrie 2007 12:56:19
Problema Multiplu Scor 0
Compilator fpc Status done
Runda preONI 2008, Runda 2, Clasa a 10-a Marime 0.7 kb
program multiplu ;
var a,b,max,max1,max2:longint;
		f,g:text;
		gasit,ok:boolean;
begin
	 assign(f,'multiplu.in');
	 reset(f);
	 assign(g,'multiplu.out');
	 rewrite(g);
	 read(f,a,b);
	 max1:=0;
	 if a>b then max:=a
	 else max:=b;
	 gasit:=false;
	 while gasit=false do
		 begin
			 max1:=max1+max;ok:=false;
			 if (max1 mod a)=0 then
					begin
						 max2:=max1;
						 while (max2<>0)and(ok=false) do
							 begin
								if((max2 mod 10=1)or(max2 mod 10=0))and(((max2 div 10) mod 10=1)or((max2 div 10) mod 10=0))then ok:=true;
								max2:=max2 div 100;
							 end;

					end;
			 if ok then gasit:=true;
		 end;
		 if gasit then write(g,max1);
		 close(f);
		 close(g);
end.