AmidamaruZXC

27

May 28th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.84 KB | None | 0 0
  1. var
  2.   N, a, m1, m2, m3, m6, x, y, i: integer;
  3.  
  4. begin
  5.   m1 := 0; m2 := 0; m3 := 0; m6 := 0;
  6.   readln(N);
  7.   for i := 1 to N do
  8.   begin
  9.     readln(a);
  10.     if a mod 2 = 0 then
  11.     begin
  12.       if a mod 3 = 0 then
  13.       begin
  14.         if a > m6 then
  15.           m6 := a
  16.       end
  17.       else
  18.       begin
  19.         if a > m2 then
  20.           m2 := a
  21.       end;
  22.     end
  23.     else
  24.     begin
  25.       if a mod 3 = 0 then
  26.       begin
  27.         if a > m3 then
  28.           m3 := a
  29.         else
  30.       begin
  31.           if a > m1 then
  32.             m1 := a
  33.         end;
  34.       end;
  35.     end;
  36.   end;
  37.  
  38.   x := m1; y := m6;
  39.   if m2 * m3 > x * y then
  40.   begin
  41.     x := m2;
  42.     y := m3;
  43.   end;
  44.   if m3 * m6 > x * y then
  45.   begin
  46.     x := m3;
  47.     y := m6;
  48.   end;
  49.   if x * y = 0 then
  50.     writeln(0)
  51.   else
  52.     writeln(x, ' ', y);
  53. end.
Advertisement
Add Comment
Please, Sign In to add comment