Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int n;
  6.     std::cin >> n;
  7.     int b = 0;
  8.     for (int i = 0; i < n; ++i)
  9.     {
  10.         int k = 0;
  11.         int x;
  12.         std::cin >> x;
  13.         while (1)
  14.         {
  15.             if (x % 4 == 0)
  16.             {
  17.                 if (x / 1000 == 4 || x / 1000 == 5)
  18.                 {
  19.                     k = 1;
  20.                 }
  21.                 else
  22.                 {
  23.                     k = 2;
  24.                     break;
  25.                 }
  26.             }
  27.             if (x % 7 == 0)
  28.             {
  29.                 if (x / 1000 == 7 || x / 1000 == 1)
  30.                 {
  31.                     k = 1;
  32.                 }
  33.                 else
  34.                 {
  35.                     k = 2;
  36.                     break;
  37.                 }
  38.             }
  39.             if (x % 9 == 0)
  40.             {
  41.                 if (x / 1000 == 9 || x / 1000 == 8)
  42.                 {
  43.                     k = 1;
  44.                 }
  45.                 else
  46.                 {
  47.                     k = 2;
  48.                     break;
  49.                 }
  50.             }
  51.             if (x % 9 != 0 || x % 7 != 0 || x % 4 != 0)
  52.             {
  53.                 k = 1;
  54.                 break;
  55.             }
  56.             break;
  57.         }
  58.         if (k == 2)
  59.         {
  60.             std::cout << x << " ";
  61.         }
  62.         else
  63.         {
  64.             ++b;
  65.         }
  66.     }
  67.     if (b == n)
  68.     {
  69.         std::cout << 0;
  70.     }
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement