Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. n = int(input())
  2. mas = [int(i) for i in range(N)]
  3.  
  4. m1 = 0
  5. m2 = 0
  6. for e in mas:
  7.     if (e % 3 == 0) and (e % 2 != 0):
  8.         m1 = max(m1, e)
  9.     if (e % 2 == 0) and (e % 3 != 0):
  10.         m2 = max(m2, e)
  11.  
  12. ans = m1 * m2
  13.  
  14. m1 = 0
  15. m2 = 0
  16. for e in mas:
  17.     if e % 6 != 0:
  18.         m2 = max(m2, e)
  19.     else:
  20.         if (e > m1):
  21.             if (m1 > m2):
  22.                 m2 = m1
  23.             m1 = e
  24.         else:
  25.             m2 = max(m2, e)
  26.  
  27. ans = max(ans, m1 * m2)
  28. if ans == 0:
  29.     print("NO SOLUTION")
  30. else:
  31.     print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement