program fraction; {$APPTYPE CONSOLE} uses SysUtils; type long=array[0..10000] of integer; var a1,b1,c1,d1:long; ii:integer; procedure per(var a:long); var i,temp:integer; begin for i:=1 to a[0] div 2 do begin temp:=a[i]; a[i]:=a[a[0]-i+1]; a[a[0]-i+1]:=temp; end; end; // виведення procedure vuvid (a:long); var i:integer; begin for i:=a[0] downto 2 do write(a[i]); writeln(a[1]); end; // // порівняння function por(a,b:long):boolean; var i:integer; begin if a[0]>b[0] then por:=true else por:=false; if a[0]=b[0] then begin i:=a[0]; while(a[i]=b[i]) and (i>1) do i:=i-1; if a[i]>=b[i] then por:=true else por:=false; end; end; //--------------сума function sum(a,b:long):long; var c:long; os,i:integer; begin if a[0]>b[0] then c[0]:=a[0] else c[0]:=b[0]; os:=0; for i:=1 to c[0] do begin c[i]:=(a[i]+b[i]+os) mod 10; os:=(a[i]+b[i]+os) div 10; end; if os>0 then begin c[0]:=c[0]+1;c[c[0]]:=os;end; sum:=c; end; // віднімання function riz(a,b:long):long; var c:long; os,i:integer; begin c[0]:=a[0]; for i:=1 to c[0] do if a[i]>=b[i] then c[i]:=a[i]-b[i] else begin c[i]:=10+a[i]-b[i]; a[i+1]:=a[i]-1; end; while c[c[0]]=0 do c[0]:=c[0]-1; riz:=c; end; //--------------добуток function dob(a,b:long):long; var d,c:long; des,temp,j,s,i:integer; begin for j:=1 to b[0] do begin des:=0; c[0]:=a[0]; for i:=1 to c[0] do begin c[i]:=(a[i]*b[j]+des) mod 10; des:=(a[i]*b[j]+des) div 10; end; if des>0 then begin c[0]:=c[0]+1;c[c[0]]:=des;end; for i:=c[0] downto 1 do c[i+j-1]:=c[i]; c[0]:=c[0]+j-1; for i:=1 to j-1 do c[i]:=0; if c[0]>=d[0] then d[0]:=c[0]; des:=0; for i:=1 to d[0] do begin temp:=(c[i]+d[i]+des) mod 10; des:=(c[i]+d[i]+des) div 10; d[i]:=temp; end; if des>0 then begin d[0]:=d[0]+1;d[d[0]]:=des;end; for i:=1 to 100 do c[i]:=0; end; dob:=d; for i:=0 to d[0] do d[i]:=0; end; //---------ділення function dil(a:long;b:integer):long; var os,i:integer; c:long; begin os:=0; for i:=a[0] downto 1 do begin c[i]:=(a[i]+os*10) div b; os:=(a[i]+os*10) mod b; end; c[0]:=a[0]; while c[c[0]]=0 do c[0]:=c[0]-1; {00000} dil:=c; end; begin readln(a1[0]); for ii:=1 to a1[0] do a1[ii]:=random(9)+1; readln(b1[0]); for ii:=1 to b1[0] do b1[ii]:=random(9)+1; per(a1); per(b1); vuvid(a1); vuvid(b1); d1:=dob(a1,b1); vuvid(d1); c1:=sum(a1,b1); vuvid(c1); c1:=dil(d1,2); vuvid(c1); c1:=riz(a1,b1); vuvid(c1); writeln(por(a1,b1)); readln; end.