Construct N solution codechef – You are given an integer NN. Find if it is possible to represent NN as the sum of several(possibly zero) 22‘s and several(possibly zero) 77‘s.
Table of Contents
[Solution] Construct N solution codechef
Formally, find if there exist two integers X,Y (X,Y≥0)X,Y (X,Y≥0) such that 2⋅X+7⋅Y=N2⋅X+7⋅Y=N.
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases.
- Each test case consists of a single line containing an integer NN.
Output Format
For each test case, print on a new line YES
if it is possible to represent NN as the sum of several(possibly zero) 22‘s and several(possibly zero) 77‘s and NO
otherwise.
You may print each character of the string in either uppercase or lowercase (for example, the strings yEs
, yes
, Yes
, and YES
will all be treated as identical).
[Solution] Construct N solution codechef
- 1≤T≤10001≤T≤1000
- 1≤N≤1081≤N≤108
Sample Input 1
4
2
5
7
11
Sample Output 1
YES
NO
YES
YES
[Solution] Construct N solution codechef
Test case 11: 2⋅1+7⋅0=22⋅1+7⋅0=2.
Test case 22: It is impossible to express 55 as a sum of several 22‘s and 77‘s.
Test case 33: 2⋅0+7⋅1=72⋅0+7⋅1=7.
Test case 44: 2⋅2+7⋅1=112⋅2+7⋅1=11.