- P32's solution
- 
            P32's Solution
- @ 2025-9-4 21:59:21
众所周知,方程 的整数解只能是 ,因此答案不大于 ,讨论答案即可。
#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;
}
