3860 - Find the Spy

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld
& %llu

Description

Whoooa! There is a spy in Marjar University. All we know is that the spy has a special ID card. Please find him out!

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains a integer N (3 <= N <= 100), which describes that there are N students need to be checked.

The second line contains N integers indicating the ID card number of N students. All ID card numbers are 32-bit integers.

Output

For each test case, output the ID card number which is different from others.

Sample Input

3
10
1 1 1 1 1 1 1 1 6 1
3
9 9 8
5
90016 90016 90016 2009 90016

Sample Output

6
8
2009

题意:找出N个数中与其他数不同的一个……

#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <memory.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    while(N--)
    {
        int n;
        int a=-1,b=-1;
        int a1=0,b1=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            int k;
            cin>>k;
            if(a==k||a==-1)a=k,a1++;
            else b=k,b1++;
        }
        printf("%d\n",a1>b1?b:a);
    }
    return 0;
}

ZOJ 3860: - Find the Spy的更多相关文章

  1. The 15th Zhejiang University Programming Contest

    a  ZOJ 3860 求和大家不一样的那个数,签到,map水之 #include<cstdio> #include<map> using namespace std; map ...

  2. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  3. zoj 2081 BFS 延迟标记 读入问题

    Mission Impossible Time Limit: 2 Seconds                                     Memory Limit: 65536 KB  ...

  4. ZOJ3860-Find the Spy

    Find the Spy Time Limit: 2 Seconds      Memory Limit: 65536 KB Whoooa! There is a spy in Marjar Univ ...

  5. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  6. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  7. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  8. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  9. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

随机推荐

  1. MVC4之ModelBinder-模型绑定

    最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精    最近在做自学MVC,遇到的问题很多,索性一点点总结 ...

  2. java 笔记(3) —— 动态代理,静态代理,cglib代理

    0.代理模式 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口. 代理类主要负责为委托类预处理消息.过滤消息.把消息转发给委托类,以及事后处理消息等. 代理类与委托类之间通常会存 ...

  3. 学习OpenCV——ORB简化版&Location加速版

    根据前面surf简化版的结构,重新把ORB检测的代码给简化以下,发现虽然速度一样,确实能省好多行代码,关键是有 BruteForceMatcher<HammingLUT>matcher的帮 ...

  4. 转:python字符串/元组/列表/字典互转

    #-*-coding:utf-8-*-  #1.字典 dict = {'name': 'Zara', 'age': 7, 'class': 'First'} #字典转为字符串,返回:<type ...

  5. Regist

    using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\Current ...

  6. 全局函数VS成员函数

    #include <iostream> using namespace std; class Test { public: Test(int a, int b) { this->a ...

  7. 02---Net基础加强

    将普通日期格式:“2014年7月8日”转换成汉字日期格式:“二零一四年七月八日”.(暂时不考虑10日,13日,23日) class Program { static void Main(string[ ...

  8. OpenStack 虚拟机监控方案确定

    Contents [hide] 1 监控方案调研过程 1.1 1. 虚拟机里内置监控模块 1.2 2. 通过libvirt获取虚拟机数据监控. 2 a.测试openstack的自待组件ceilomet ...

  9. expandlistview

    package com.exaple.zhonghe2; import java.sql.SQLData;import java.util.ArrayList;import java.util.Has ...

  10. css中的选择器

    选择器            说明    *                通用元素选择器,匹配任何元素    E                标签选择器,匹配所有使用E标签(所有HTML元素)的元 ...