#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
pair<int, int> gettwonums(vector<int>& A,const int& K)
{
	unordered_map<int,int> res;
	res.rehash(A.size() * 2);
	for (auto &a : A)
	{
		auto ret=res.insert({ a,1 });
		if (ret.second == false)
			(ret.first)->second++;
	}
	for (auto a :res)
	{
		auto ret = res.insert({ K - a.first,1 });
		if (ret.second == false)
		{
			if (2 * a.first == K&&a.second > 1)
				return make_pair(a.first, K - a.first);
			else if (2 * a.first != K)
				return make_pair(a.first, K - a.first);
		}
	}
	return  make_pair(0,0);
}
int main()
{
	vector<int> A = { 5,8,6,7,9};
	auto a = gettwonums(A, 10);
	cout << a.first << " " << a.second;
	system("pause");
}
输出2,8.。。。。不知道为啥