Advertisement
_takumi

num27.2

Oct 22nd, 2020
2,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int now = 0, maximum = 0, mod14 = 0, mod7 = 0, mod2 = 0;
  9.     ifstream input("C:\\Users\\Максим\\Downloads\\27-A_2.txt");
  10.     input >> now;
  11.     while (input >> now) {
  12.         if (now % 14 == 0 && now > mod14) {
  13.             mod14 = now;
  14.         }
  15.         else {
  16.             if (now > maximum) {
  17.                 maximum = now;
  18.             }
  19.  
  20.             if (now % 7 == 0 && now > mod7) {
  21.                 mod7 = now;
  22.             }
  23.             else if (now % 2 == 0 && now > mod2) {
  24.                 mod2 = now;
  25.             }
  26.         }
  27.     }
  28.     cout << max(mod7 * mod2, mod14 * maximum);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement