Files
python/TangDou/XiTi/1329.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
650 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
int main() {
int n;
cin >> n;
unordered_map<int, int> _map;
for (int i = 0; i < n; i++) {
int c;
cin >> c;
if (c > 0) {
_map[c] = 1;
} else {
if (_map.count(abs(c)) > 0) {
_map[abs(c)]++;
}
}
}
//遍历map找到值为2的
int count = 0;
unordered_map<int, int>::iterator it = _map.begin();
while (it != _map.end()) {
if (it->second == 2) count++;
it++;
}
cout << count << endl;
return 0;
}