/*
author:谦智
find your present (2) hdoj 2095
法一:用暴力
法二:用map
法三:
符号是^.
异或是个位运算符号,具体是怎么操作的请百度,这里有个特性使得他能产生一种巧方法
a^a=0
0^c=c 看到上面这个式子是否你懂了呢?
没错,例如样例
5
1 1 3 2 2
如果我们用异或运算计算就是
1^1^3^2^2 由于1^1=0 2^2=0,那么就只剩下了唯一的一个3了。
如果有3个3,那么前面偶数个3由于3^3=0,势必也会只留下一个孤单的3. 那么答案就只能是那个多余的数字了。 */ //#include<iostream>
//#include<cstdio>
//using namespace std;
//int main() {
// int n;
// while (scanf("%d",&n),n) {
// int ans = 0;
// for (int i = 0; i < n; i++) {
// int x;
// scanf("%d",&x);
// ans ^= x;
// }
// printf("%d\n",ans);
// }
//} //#include<iostream>
//using namespace std;
//int main() {
// int n;
// while (cin >> n, n) {
// int ans = 0;
// for (int i = 0; i < n; i++) {
// int x;
// cin >> x;
// ans ^= x;
// }
// cout << ans << endl;
// }
//} //map 改题设定为c的输入输出
#include<iostream>
#include<map>
#include<cstdio>
using namespace std;
int main() {
int n;
while (scanf("%d",&n),n) {
map<int,int> Map;
for (int i = ; i < n; i++) {
int x;
scanf("%d",&x);
Map[x]++;
}
map<int,int>::iterator it = Map.begin();
for (; it != Map.end(); it++) {
if (it->second%) {
printf("%d\n",it->first);
break;
}
}
}
}

最新文章

  1. 剑指Offer面试题:15.反转链表
  2. java高新技术-可变参数与OverLoad相关面试题分析
  3. f
  4. Charles V4系列更新 | 绿色特别版 | 视频教程
  5. AndroidStudio调试APP
  6. 【LeetCode】168 &amp; 171- Excel Sheet Column Title &amp; Excel Sheet Column Number
  7. [LeetCode] Two Sum水过
  8. 关于C51内的code,idata,xdata
  9. Deme_遥感控制物体移动(涉及遮罩,小摄像机跟随)
  10. Android MVC框架模式
  11. SQL练习1关于插入删除,修改,单表查询
  12. 3_使用指针对象(Using Object Pointer)
  13. Angular记录(5)
  14. SpringBoot集成监控管理
  15. [转载] About Career Promotion and Tutoring from Zhihu Web FAQer (Quoted Entirely Without Personal Idea. Delete Immediately If Pirated)
  16. Vue2.5开发去哪儿网App 第五章笔记 下
  17. Angular中ui-select的使用
  18. 解问 lambda表达式
  19. 歌手右侧快速入口ABCD....
  20. Hyper-V如何新建虚拟机

热门文章

  1. Excel阅读模式/单元格行列指示/聚光灯开发 技术要点再分享
  2. MySQL-悲观锁和乐观锁
  3. pytorch识别CIFAR10:训练ResNet-34(数据增强,准确率提升到92.6%)
  4. hdu4843(NOI2000) 古城之谜 (trie树+DP)
  5. Leetcode 8 Two Pointers
  6. ubuntu下面配置apache
  7. BZOJ2339[HNOI2011]卡农——递推+组合数
  8. Android Connection refused
  9. 我的python之路
  10. 升级 pip 超时解决方案