题意

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

思路

用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. 小程序图表功能wxchart实现

    在开发小程序过程中,有项目用到图表功能, 其实Echart.js有小程序的库,我们要吧引入进来,然后配置初始化一下,就可以达到目的了.接下来就开始步骤吧 首先下载JS库:http://download ...

  2. FAT32和NTFS最大支持的单个文件大小分别是多大?

    以前,RAID控制器和文件系统都有2TB的限制.控制器上的限制,主要是指每个LUN不能大于2TB,而磁盘组一般则没有这个限制:文件系统的限制主要是指每个分区(partition)不能大于2TB,不过3 ...

  3. iOS一些基础面试题

    Part One 别人问你你都感觉这尼玛说啥的基础面试题 1.UIWindow和UIView和 CALayer 的联系和区别? 答:UIView是视图的基类,UIViewController是视图控制 ...

  4. python之函数enumerate()

    enumerate函数可以遍历列表 for i in range(len(a)): print a[i] 等价于: for index,item in enumerate(a): print inde ...

  5. Response设置response header

    total : #常见状态码:服务器处理请求的结果状态 200 : 表示请求处理完成并完美返回; 302 : 表示请求需要进一步细化; 404 : 表示客户访问资源Not Found; 500 : 表 ...

  6. 一种安全云存储方案设计(下)——基于Lucene的云端搜索与密文基础上的模糊查询

    一种安全的云存储方案设计(未完整理中) 一篇老文了,现在看看错漏颇多,提到的一些技术已经跟不上了.仅对部分内容重新做了一些修正,增加了一些机器学习的内容,然并卵. 这几年来,云产品层出不穷,但其安全性 ...

  7. java blob

    package net.qysoft; import java.io.File;import java.io.FileOutputStream;import java.sql.Blob;import ...

  8. PostgreSQL tips

    tip 1 在sql中我们可以设置一个列自增长identity(1,1),但在postgresql中却没有这个关键字定义.但postgresql也有实现相关功能,那就是只需要将该列数据类型标记为ser ...

  9. 【泰语歌】กลับคำสาหล่า 歌手:Mike Piromporn

    Darling,Please don't leave me. 很短的一句话,可能会摧毁我们在一起的所有美好时光.

  10. django 1.10以上版本,引入js

    引入js库 建立static文件夹:  注意上图里面static文件夹的路径,再在里面添加js文件夹,js文件夹里面就可以放我们需要的js文件了. 配置相关文件 接下来,想要使用这些js我们还需要进行 ...