合肥工业大学oj 1321 相反数

#include<iostream>
#include<cmath> 
#include<set>
using namespace std;

int N;

int main(){
    while(cin >> N){
        set<int> set;
        for(int i = 0; i < N; i++){
            int num;
            cin >> num;
            set.insert(abs(num));//利用set的查重功能,如果set中已经存在相同的数字,则不会再插入同样的数字
        }
        cout << N - set.size() << endl;
    }
    
    return 0;
}

//presented by 大吉大利,今晚AC

猜你喜欢

转载自blog.csdn.net/lalala_HFUT/article/details/88063378