可以假定这样的数字x = 7a + 3b,那么取t = x % 7,t 在[0,6]范围内,t = 3k时自然可行,t=其他情况时讨论即可。
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#define MAX 100005
#define mod 998244353ll
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
int main() {
freopen("a.txt", "r", stdin);
freopen("b.txt", "w", stdout);
int n, x;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> x;
int t = x % 7;
if (t == 0) {
cout << "YES" << endl;
}
else if (t == 1 && x / 7 >= 2) {
cout << "YES" << endl;
}
else if (t == 2 && x / 7 >= 1) {
cout << "YES" << endl;
}
else if (t == 3) {
cout << "YES" << endl;
}
else if (t == 4 && x / 7 >= 2) {
cout << "YES" << endl;
}
else if (t == 5 && x / 7 >= 1) {
cout << "YES" << endl;
}
else if (t == 6) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}