题意

给出一系列数字,输出那个出现次数为奇数次的数字

思路

用MAP标记一下,在输入的时候判断一下 之前有没有输入过,如果有,就抹掉 最后剩下的那个 就是出现次数为奇数的

或者可以用 位运算

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7; int main()
{
int n;
cin >> n;
map <int, int> m;
m.clear();
for (int i = 0; i < n; i++)
{
int num;
scanf("%d", &num);
if (m[num] == 1)
m.erase(num);
else
m[num] = 1;
}
map <int, int>::iterator it;
it = m.begin();
cout << it -> first << endl;
}

HackerRank - lonely-integer 【水】的更多相关文章

  1. 【HackerRank】Lonely Integer

    There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the ...

  2. Lonely Integer

    https://www.hackerrank.com/challenges/lonely-integer def main(): n = int(raw_input()) s = dict() a = ...

  3. Leetcode 13. Roman to Integer(水)

    13. Roman to Integer Easy Roman numerals are represented by seven different symbols: I, V, X, L, C, ...

  4. HackerRank - maximum-perimeter-triangle 【水】

    题意 给出一系列数字,判断其中哪三个数字可以构成一个三角形,如果有多个,输出周长最大的那个,如果没有输出 - 1 思路 数据较小,所有情况FOR一遍 判断一下 AC代码 #include <cs ...

  5. Leetcode OJ 刷题

    Valid Palindrome吐槽一下Leetcode上各种不定义标准的输入输出(只是面试时起码能够问一下输入输出格式...),此篇文章不是详细的题解,是自己刷LeetCode的一个笔记吧,尽管没有 ...

  6. Codeforces Round #440 (Div. 2) A,B,C

    A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input ...

  7. Educational Codeforces Round 58 (Rated for Div. 2)

    A. Minimum Integer 水 #include<bits/stdc++.h> #define clr(a,b) memset(a,b,sizeof(a)) using name ...

  8. 水题两篇 Dream & Find Integer (HDU 6440/6441)

    // 出自ICPC 2018网络赛C - Dream & D - Find Integer // 对大佬来讲的水题,本菜鸡尽量学会的防爆零题... // 今晚翻看vjudge昨日任务上的C题, ...

  9. HDU 1047 Integer Inquiry( 高精度加法水 )

    链接:传送门 思路:高精度水题 /************************************************************************* > File ...

随机推荐

  1. jstat -gcutil pid millsec

      1. jstat -gc pid 可以显示gc的信息,查看gc的次数,及时间. 其中最后五项,分别是young gc的次数,young gc的时间,full gc的次数,full gc的时间,gc ...

  2. imx6背光驱动调试

    1.内核配置pwm背光驱动make menuconfig:Device Driver ---> Graphics support ---> [*] Backlight & LCD ...

  3. 百度UEditor 用require 引入 Thinkphp5 ,图片上传问题

    用require引入,用了10分钟:上传图片,用了一个早上(吐血一地.....) 重点:require引入成功后,在需要引用UEditor的文件开头加入(ue的文件夹路径) window.UEDITO ...

  4. Matlab字符串分割

    data = '1.21, 1.985, 1.955, 2.015, 1.885'; C = strsplit(data,', ') C = '1.21' '1.985' '1.955' '2.015 ...

  5. sqlserver tips

    方括号内的表示一个对象名(视图,存储过程,表 等).列名:正常使用时,加不加一样,但是如果对象名是保留字的话,比如cascade,就必须加:不过建议不用保留字作为对象名 if object_id('[ ...

  6. mysql 年龄计算(根据生日)

    生日(DATE) 计算方法1: ))) 计算方法2: year( from_days( datediff( now( ), birthdate))) now() 当前时间,精确到秒 datediff( ...

  7. HashMap的clear()方法和new HashMap的效率问题

    最近研究Lucene的时候,遇到的用到大量Map的问题,心生好奇,想看一下在1W,10W,100W三种数据量下,new HashMap ,与 HashMap.clear()方法的效率问题. 提前说明: ...

  8. JAVA学习第六十三课 — 关于client服务端 &amp;&amp; URL类 &amp; URLConnection

    常见的client和服务端 client:       浏览器:IE:弹窗体,猎豹:弹窗体.多标签,争强效果 服务端:       server:TomCat:1.处理请求 2.给予应答 想让TomC ...

  9. XML 文档的结构

    XML 文档的组成 一个XML文档由两部分构成:第一部分是文档序言,第二部分是文档元素(节点). 1.文档序言 文档序言通常位于XML文档的顶端,根元素之前出现,它是一个特定的包含XML 文档设定信息 ...

  10. HDU4027(Can you answer these queries?)

    题目链接:传送门 题目大意:有一个长度为n的数组,有m次操作,每次操作输入 v x y,v==0时x~y区间内的数都开平方并且向下取整,v==1时求x~y区间内所有数的和. 题目思路:long lon ...