思路非常简单,但是对我感觉比较难想
sum总和
sum_异或和
sum + sum_ + x = 2 * x
解得,x = sum + sum_
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> PII;
#define pb emplace_back
//#define int ll
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define ps push_back
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc u << 1
#define rc u << 1 | 1
void solve();
const int N = 1e6 + 10;
signed main() {
IOS;
ll t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
//sum+ === ___(suoyoujin)
void solve() {
ll n; cin >> n;
vector<ll> a(n+1);
ll sum = 0,sum_ = 0;
for(int i = 1; i <= n; ++ i)
{
cin >> a[i];
sum_ = sum_ ^ a[i];
sum += a[i];
}
if((sum_<<1) == sum)
{
cout << 0 << endl;
cout << endl;
return;
}
cout << 2 << endl;
cout << sum_ << " " << sum_ + sum << endl;
}