zoukankan      html  css  js  c++  java
  • Codeforces Round #436 A. Fair Game

    题意:给你n张卡片,上面写有数字,两个人选择两个数字,把相同数字的卡片都拿走,问能不能拿走所有的卡片并且两个人拿的卡片书相同。

    Examples
    Input
    4
    11
    27
    27
    11
    Output
    YES
    11 27
    Input
    2
    6
    6
    Output
    NO
    Input
    6
    10
    20
    30
    20
    10
    20
    Output
    NO
    Input
    6
    1
    1
    2
    2
    3
    3
    Output
    NO

    思路:水题啊,瞎搞搞记录一下就好了,看题太不仔细了,还以为每个人能拿多张卡片orz。

    代码:
    #include<iostream>
    #include<string.h>
    using namespace std;
    int vis[110];

    int main(){
        int n,x,sum1=0,sum2=0,c=1,k1,k2;
        bool f=1;
        memset(vis,0,sizeof(vis));
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>x;
            if(vis[x]==0){
                if(c==3){
                    f=0;
                    break;
                }
                else if(c==1)k1=x,vis[x]=c++;
                else if(c==2)k2=x,vis[x]=c++;
            }
            if(vis[x]==1)sum1++;
            else sum2++;
        }
        if(f&&c==3&&sum1==sum2){
            cout<<"YES"<<endl;
            cout<<k1<<' '<<k2<<endl;
        }
        else cout<<"NO"<<endl;
        return 0;    
    }

  • 相关阅读:
    centos 7 安装zabbix 4.0
    django Middleware
    初探paramiko
    python中的反射
    python异常处理
    双绞线
    简易的CMDB服务端
    4-初识Django Admin
    数据资产管理实践纲要
    matplotlib 散点图,为不同区域的点添加不同颜色
  • 原文地址:https://www.cnblogs.com/ljy08163268/p/7634626.html
Copyright © 2011-2022 走看看