Advertisement
vovanhoangtuan

903A - Hungry Student Problem

Nov 2nd, 2020
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool task(int x)
  6. {
  7.     for (double i = 0; i * 7 <= x; i++)
  8.     {
  9.         double temp = ((x - (7 * i)) / 3);
  10.         if (temp == (int)temp) return true;
  11.     }
  12.     return false;
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18.  
  19.     int n;
  20.     cin >> n;
  21.     while (n--)
  22.     {
  23.         int temp;
  24.         cin >> temp;
  25.         if (task(temp)) cout << "YES" << endl;
  26.         else cout << "NO" << endl;
  27.     }
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement