HDU 5650 so easy

http://acm.hdu.edu.cn/showproblem.php?pid=5650

数学规律  

如果只有一个数 输出

多个数 由于异或运算满足交换律 S的所有子集的元素异或 那么原子元素出现的次数是2^(n-1) 一定是偶数 那么异或的结果是0

 1 #include <iostream>
 2 #include <bits/stdc++.h>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int T;
 9     cin >> T;
10     while (T--)
11     {
12         int n;
13         int ans;
14         cin >> n;
15         for(int i = 0; i < n; i++)
16         {
17             cin >> ans;
18         }
19         if (n == 1) cout << ans << endl;
20         else cout << 0 << endl;
21     }
22     return 0;
23 }

 

posted @ 2017-04-21 21:05  Lorazepam  阅读(180)  评论(0编辑  收藏  举报