E: CS Course
时间限制: 2 Sec 内存限制: 512 MB 提交: 79 解决: 21 [ ][ ][ ]题目描述
Little A has come to college and majored in Computer and Science. Today he has learned bit-operations in Algorithm Lessons, and he got a problem as homework. Here is the problem: You are giving n non-negative integers a1,a2,...,an, and some queries. A query only contains a positive integer p, which means you are asked to answer the result of bit-operations (and, or, xor) of all the integers except ap.
输入
There are no more than 15 test cases. Each test case begins with two positive integers n(2 ≤ n ≤ 105) and p(2 ≤ p ≤ 105) in a line, indicate the number of positive integers and the number of queries. Then n non-negative integers a1,a2,...,an follows in a line, 0 ≤ ai ≤ 109 for each i in range [1,n]. After that there are q positive integers p1, p2, ...,pq in q lines, 1 ≤ pi ≤ n for each i in range [1,q].
输出
For each query p, output three non-negative integers indicates the result of bit-operations(and, or, xor) of all non-negative integers except ap in a line.
样例输入
3 3
1 1 1
1
2
3
样例输出
1 1 0
1 1 0
1 1 0
提示
亦或 可以直接 在亦或第x 个值 得数,
与和 或 要 转换成 二进制, 用数组 统计 数
对于& 而言, 如果 1的数目= n-1 并且 x%2 =0 则 结果为1;
对于| 而言, 只要存在1, 结果为1
代码:
#include#include #include #include #include #include #include #include #include #include #include
13