HackerRank - lonely-integer 【水】
题意
给出一系列数字,输出那个出现次数为奇数次的数字
思路
用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 【水】的更多相关文章
- 【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 ...
- Lonely Integer
https://www.hackerrank.com/challenges/lonely-integer def main(): n = int(raw_input()) s = dict() a = ...
- Leetcode 13. Roman to Integer(水)
13. Roman to Integer Easy Roman numerals are represented by seven different symbols: I, V, X, L, C, ...
- HackerRank - maximum-perimeter-triangle 【水】
题意 给出一系列数字,判断其中哪三个数字可以构成一个三角形,如果有多个,输出周长最大的那个,如果没有输出 - 1 思路 数据较小,所有情况FOR一遍 判断一下 AC代码 #include <cs ...
- Leetcode OJ 刷题
Valid Palindrome吐槽一下Leetcode上各种不定义标准的输入输出(只是面试时起码能够问一下输入输出格式...),此篇文章不是详细的题解,是自己刷LeetCode的一个笔记吧,尽管没有 ...
- 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 ...
- 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 ...
- 水题两篇 Dream & Find Integer (HDU 6440/6441)
// 出自ICPC 2018网络赛C - Dream & D - Find Integer // 对大佬来讲的水题,本菜鸡尽量学会的防爆零题... // 今晚翻看vjudge昨日任务上的C题, ...
- HDU 1047 Integer Inquiry( 高精度加法水 )
链接:传送门 思路:高精度水题 /************************************************************************* > File ...
随机推荐
- 使用spring-boot-maven-plugin打包
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> ...
- php对gzip文件或者字符串解压实例参考
要采集一个网站,目标站采用了gzip压缩传输网页,本来应该只要发送一个http头 Accept-Encoding: identity或者干脆不发送这个头等,就可以使目标站返回没有经过gzip压缩的页面 ...
- Chromium浏览器组件设计意图
在文章開始之前.我要叽歪几句,一上来就看Chrome的代码.简直晕头转向,摸来摸去莫不着头脑,好不easy看了一点点代码.却犹如瞎子摸象.无法众观全局.以下这篇小文,简介当中一个重要的模块--Comp ...
- sql server case when then
http://blog.csdn.net/wuxiaokaixinguo/article/details/8895187
- Unity3D学习笔记——NGUI之Property Binding
Property Binding:用于绑定两个组件,然后可以将一个组件的信息发送给另一个组件. 效果图如下: 一:使用步骤 1.建立一个Sprite 2.建立一个Label 3.为Sprite添加Pr ...
- ssl 生成证书
使用OpenSSL生成证书 1.生成RSA密钥的方法 openssl genrsa -des3 -out privkey.pem 2048 这个命令会生成一个2048位的密钥,同时有一个des3方法加 ...
- 转载:DenseNet算法详解
原文连接:http://blog.csdn.net/u014380165/article/details/75142664 参考连接:http://blog.csdn.net/u012938704/a ...
- eclipse4.2+安装modelgoon插件,该插件支持在eclipse直接依据java文件生产类图
安装条件: 1. 确保JDK环境OK 2.该插件安装是基于eclipse kepler(4.2) (并非表示其它版本号不能安装,仅仅是博主仅仅在4.2版本号上測试了.预计4.3版本号还是支持的,可是3 ...
- 45、Android事件总线分发库的使用
事件总线分发库EventBus和Otto的简介及对比 什么是事件总线管理: a.将事件放到队列里,用于管理和分发b.保证应用的各个部分之间高效的通信及数据.事件分发c.模块间解耦 Event Bus是 ...
- PhotoSwipe异步动态加载图片
在开发搜房家居M站的时候,搜房家居装修效果图相册展示效果需要用到PhotoSwipe插件来显示图片.特点:1. 家居提供的接口,每次只能获取一张图片2. 装修效果图的张数不限.3. 从PhotoSwi ...