• codeforces 291A. Spyke Talks


    判断公司内两两聊天的人有多少对,注意不聊天的以及和公司以外的人聊天的人

    #include <stdlib.h>

    #include <string.h>
    #include <stdio.h>
    #include <ctype.h>
    #include <math.h>
    #include <stack>
    #include <queue>
    #include <map>
    #include <set>
    #include <vector>
    #include <string>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    #define ll long long
    #define ls rt<<1
    #define rs ls1
    #define lson l,mid,ls
    #define rson mid+1,r,rs
    #define middle (l+r)>>1
    #define eps (1e-9)
    #define clr_all(x,c) memset(x,c,sizeof(x))
    #define clr(x,c,n) memset(x,c,sizeof(x[0])*(n+1))
    #define MOD 1000000007
    #define inf 100000007
    #define pi acos(-1.0)
    #define M 1000+5
    map<int,int>mp;
    map<int,int>::iterator m0;
    int main(){
        int n,i,j,flag,cnt,x;
        while(~scanf("%d",&n)){
    mp.clear();
    j=0;
    while(n--){
    scanf("%d",&x);
    if(mp.find(x)==mp.end())mp[x]=1,j++;
    else mp[x]++;
    }
    cnt=0;flag=0;
    for(m0=mp.begin();m0!=mp.end();m0++){
    if(m0->first!=0&&m0->second>2){
    flag=1;
    break;
    }else if(m0->first!=0&&m0->second==2)cnt++;
    }
    if(flag!=0)cnt=-1;
    printf("%d\n",cnt);
    }
        return 0;
    }

    每天进步一点,永不停止
  • 相关阅读:
    hdu 1695 GCD(欧拉函数+容斥)
    hdu 5072 Coprime (容斥)
    hdu 4135 Co-prime(容斥)
    畅通工程,继续畅通工程,畅通工程再续,多种解法
    Palindrome
    括号匹配(二)(动态规划)
    搬寝室(动态规划)
    Common Subsequence(lcs)
    周赛题解
    亲和串(两种方法妙解)
  • 原文地址:https://www.cnblogs.com/fanzhongrui/p/3118116.html
Copyright © 2020-2023  润新知