赞
踩
201403-1 相反数
#include <iostream> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 510; int n, a[MAXN]; int cnt[MAXN]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); cnt[abs(a[i])]++; } int res = 0; for (int i = 0; i < n; ++i) if (cnt[abs(a[i])] == 2) res++; res /= 2; printf("%d", res); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。