洛谷P1469

P1469 找筷子

亏我是电子信息大类的,异或想半天没想到

点击查看代码
#include<bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    int atmp;
    int ans = 0;

    for(int i = 1; i <= n; i++) {
        cin >> atmp;
        ans ^= atmp;//0 ^ a = a; a ^ a = 0;
    }
    cout << ans << '\n';
    return 0;
}
posted @ 2025-05-19 03:41  Chuan81  阅读(8)  评论(0)    收藏  举报