一二三四五 上山打老虎

CCF-CSP-2014-03-1相反数

链接:http://118.190.20.162/view.page?gpid=T10

代码:

#include<bits/stdc++.h>

using namespace std;
unordered_map<int,int>mp;

int main (){
    int n,num,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>num;
        if(mp.find(-num)!=mp.end())ans++;
        else mp[num]=1;
    }
    cout<<ans;
    return 0;
}

posted @ 2021-03-27 19:17  黒川川  阅读(42)  评论(0)    收藏  举报