您的位置:首页 > 其它

hdu 4696 Answers(规律)

2015-11-12 14:38 288 查看
题目链接:hdu 4696 Answers

解题思路

只要存在一个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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: