这个视频讲的比较清楚:

https://www.bilibili.com/video/BV1ns4y1D7dg/?spm_id_from=333.337.search-card.all.click&vd_source=7201fdad1e40a4f667744bb483446a7d

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    scanf("%d,%d,%d", &a, &b, &c);
    int xorSum = a ^ b ^ c;
    if (xorSum == 0) {
        cout << 1 << endl;
    } else {
        if (a >= (a ^ xorSum)) {
            cout << "A," << (a - (a ^ xorSum)) << endl;
        } else if (b >= (b ^ xorSum)) {
            cout << "B," << (b - (b ^ xorSum)) << endl;
        } else if (c >= (c ^ xorSum)) {
            cout << "C," << (c - (c ^ xorSum)) << endl;
        }
    }
    return 0;
}

时间复杂度:O(1)

空间复杂度:O(1)