hdu 4696 Answers(规律)

来源:互联网 发布:2016最新网络歌曲试听 编辑:程序博客网 时间:2024/06/05 19:42

题目链接: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;}
0 0
原创粉丝点击