P1469 找筷子
题目链接https://www.luogu.com.cn/problem/P1469
异或运算
1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 int a; 5 int ans=0; 6 int main() 7 { 8 cin>>n; 9 while(n--) 10 { 11 cin>>a; 12 ans=ans^a;//偶数个数的异或结果为0,奇数个数的异或结果为数本身,0与任何数的异或值等于任何数 13 } 14 cout<<ans; 15 return 0; 16 }