算法:哈希表
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i) {
cin >> nums[i];
}
int target;
cin >> target;
unordered_map<int, int> hash_map;
for (int i = 0; i < n; ++i) {
int complement = target - nums[i];
if (hash_map.find(complement) != hash_map.end()) {
cout << hash_map[complement] << " " << i << endl;
return 0;
}
hash_map[nums[i]] = i;
}
return 0;
}