Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int a0, b0, a2, b2, a5, b5, i, n, a, max;
  7. a0 = 0;
  8. b0 = 0;
  9. a2 = 0;
  10. b2 = 0;
  11. a5 = 0;
  12. b5 = 0;
  13.  
  14. cin >> n;
  15.  
  16. for (int i = 0; i < n; i++){
  17. cin >> a;
  18. if ( a % 2 != 0 && a % 5 != 0 && a >= a0){
  19. b0 = a0;
  20. a0 = a;
  21. }
  22. if ( a % 2 != 0 && a % 5 != 0 && a >= b0 && a < a0)
  23. b0 = a;
  24.  
  25. if ( a % 2 != 0 && a % 5 == 0 && a >= a0 ){
  26. b5 = a5;
  27. a5 = a;
  28. }
  29. if ( a % 2 != 0 && a % 5 == 0 && a >= b5 && a < a5)
  30. b5 = a;
  31.  
  32. if ( a % 2 == 0 && a % 5 != 0 && a >= a2){
  33. b2 = a2;
  34. a2 = a;
  35. }
  36. if ( a % 2 == 0 && a % 5 != 0 && a >= b0 && a < a0)
  37. b2 = a;
  38. }
  39.  
  40. max = a0*b0;
  41. if (a0*a2 > max)
  42. max = a0*a2;
  43. if (a0*a5 > max)
  44. max = a0*a5;
  45. if (a5*b5 > max)
  46. max = a5*b5;
  47. if (a2*b2 > max)
  48. max = a2*b2;
  49.  
  50. cout << max << endl;
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement