解题思路
只要存在一个c为1的即所有m大于0的都可以构成,如果不存在c为1,则m为大于0的偶数可以构成
代码
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main () {
int n, m;
while (scanf("%d%d", &n, &m) == 2) {
int c = 0, x;
for (int i = 1; i <= n; i++) scanf("%d", &x);
for (int i = 1; i <= n; i++) {
scanf("%d", &x);
if (x == 1) c = 1;
}
for (int i = 0; i < m; i++) {
scanf("%d", &x);
if (x > 0 && (c == 1 || (x % 2 == 0)))
printf("YES\n");
else printf("NO\n");
}
}
return 0;
}