众所周知,方程 2x+2y=2z2^x+2^y=2^z 的整数解只能是 x=y=z1x=y=z-1,因此答案不大于 33,讨论答案即可。

#include <bits/stdc++.h>
using namespace std;
int a[200012];
map<int, int> p; 
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		p[x] = 1; 
	}
	for (map<int, int>::iterator s = p.begin(); s != p.end(); s++)
		for (int j = 0; j <= 30; j++)
			if (p.count((s -> first) - (1 << j)) && p.count((s -> first) + (1 << j)))
			{
				cout << 3 << endl;
				cout << (s -> first) - (1 << j) << ' ' << (s -> first) << ' ' << (s -> first) + (1 << j) << endl;
				return 0;
			}
	for (map<int, int>::iterator s = p.begin(); s != p.end(); s++)
		for (int j = 0; j <= 30; j++)
			if (p.count((s -> first) + (1 << j)))
			{
				cout << 2 << endl;
				cout << (s -> first) << ' ' << (s -> first) + (1 << j) << endl;
				return 0;
			}
	cout << 1 << endl;
	cout << ((p.begin()) -> first) << endl;
	return 0;
}