HDU 2095 find your present (2)

1543:【例 3】与众不同-2019.12.09.pdf 1543:【例 3】与众不同-2019.12.09 立即下载

find your present (2)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/1024 K (Java/Others)
Total Submission(s): 15230    Accepted Submission(s): 5770


Problem Description
In the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of presents now putting on the desk, and only one of them will be yours.Each present has a card number on it, and your present's card number will be the one that different from all the others, and you can assume that only one number appear odd times.For example, there are 5 present, and their card numbers are 1, 2, 3, 2, 1.so your present will be the one with the card number of 3, because 3 is the number that different from all the others.
 

Input
The input file will consist of several cases. 
Each case will be presented by an integer n (1<=n<1000000, and n is odd) at first. Following that, n positive integers will be given in a line, all integers will smaller than 2^31. These numbers indicate the card numbers of the presents.n = 0 ends the input.
 

Output
For each case, output an integer in a line, which is the card number of your present.
 

Sample Input
  
5 1 1 3 2 2 3 1 2 1 0
 

Sample Output
  
3 2
Hint
Hint
use scanf to avoid Time Limit Exceeded
 

Author
8600
 

Source
 

Recommend
8600   |   We have carefully selected several similar problems for you:   1593  1595  1599  1594  1598 
 

Statistic |  Submit |  Discuss |  Note

#include<stdio.h>
int main()
{
    int n,m,s;
    while(scanf("%d",&n)!=EOF&&n)
    {
        s=0;
        while(n--)
        {
            scanf("%d",&m);
            s^=m;
        }
        printf("%d\n",s);
    }
    return 0;
}

或者还有一种普通的做法:

#include<stdio.h>
#include<iostream>
#include<map>
using namespace std;
int main()
{
    map<int,int> s;
    int n;
    while(scanf("%d",&n)&&n)
    {
        s.clear();
        while(n--)
        {
            int x;
            scanf("%d",&x);
            s[x]++;
        }
        map<int,int>::iterator i;
        for(i=s.begin();i!=s.end();i++)
        {
            if(i->second==1)
            {
             printf("%d\n",i->first);
            }
        }
    }

    return 0;

}


Xilinx Blockset Counter计数器模块使用及参数配置 本文详细介绍了Simulink中Xilinx Blockset库Counter模块的使用以及参数说明。 阅读详情

相关推荐

有限元缺陷:剪切锁死

有限元缺陷:剪切锁死

wsxww11的博客 5189

HDU 2095:find your present (2) 两种思路

HDU 2095:find your present (2) HDU2095链接 Problem Description In the new year party, everybody will get a “special present”.Now it’s your turn to get your special present, a lot of presents now putting...

qq_45863710的博客 635

上网第二课:办了百兆宽带,为什么测速只有一半?

最慢的那一环。

qq_36765170的博客 110

1543:与众不同(RMQ+二分细节处理

#include <bits/stdc++.h> using namespace std; const int logn = 21; const int N = 2e5+10; int f[N][logn + 1], Logn[N + 1]; int n,m,st[N],a[N];map<int,int> pr; void pre() { Logn[1]=0;Logn[2]=1; for(int i=3;i<N;i++) Logn[i]=Logn[i/2]+1;

我们仍未知道那天所看见的花的名字。 707

Rockchip硬件编码实战:5分钟搞定RK3588上的H.265视频压缩(附FFmpeg集成指南)

本文深入解析了在Rockchip RK3588平台上利用硬件编码器实现高效H.265视频压缩的完整实战流程。文章详细介绍了MPP库的基础使用、FFmpeg集成方法,并重点分享了零拷贝、多实例编码等关键性能优化技巧,帮助开发者充分发挥RK3588的硬件编码能力,实现从YUV原始数据到高质量H.265码流的高效转换。

h6i7j8的博客 1098

深入C6678启动流程:从BootRom参数表到多核镜像部署的完整解析

本文深入解析TMS320C6678 DSP的启动流程,从BootRom参数表到多核镜像部署的全过程。详细介绍了七种启动模式的工程选择、多核镜像构建技巧以及二级引导策略,帮助开发者掌握C6678的启动机制与调试方法,提升嵌入式系统开发效率。

weixin_30505225的博客 612

快乐地打牢基础(3)——RMQ问题

RMQ问题是Range Maximum(Minimum) Query的缩写,就是查询某个区间的最大最小值,可以使用线段树,ST表,笛卡尔树上求LCA等多种方法求。ST表由于之前已经写过了博客,所以直接上题。 一本通 OJ:http://ybt.ssoier.cn:8088/ 【例题1】 1541 数列区间最大值 题意: 输入一串数字,给你 M 个询问,每次询问就给你两个数字 X,Y,要求你说出...

Miserable_ccf的博客 595

关于在线excel插件Univer笔记教程

univer在线excel插件确实是够强大,但也存在不少bug,用户用起来是真的很爽,和本地的wps差不多,但真正的开发起来是真的费劲。由于文档提供的信息不足,我们很多功能只能去看他们插件里的源代码,然后一点点测试,一点点尝试研究。此文章可省去五天的研究成本

guiplan 5827

hdu 2095 find your present (2)

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2095 hdu 2095 find your present (2) Description In the new year party, everybody will get a "special present".Now it's your turn to get your s...

dong12276的博客 103

YOLOv11魔改高效涨点 | 注意力篇 | SimAM注意力:基于神经科学的 3D 注意力机制,三维权重的暴力美学,无参数也能暴力涨点?代码极简,彻底疯狂!!!

在本文中,我们为卷积神经网络(ConvNets)提出了一个概念简单但非常有效的注意力模块。与现有的通道注意力(Channel-wise)和空间注意力(Spatial-wise)模块不同,我们的模块在不向原始网络添加参数的情况下,推断出层中特征图的 3D 注意力权重。具体来说,我们基于一些知名的神经科学理论,提出优化一个能量函数来寻找每个神经元的重要性。我们进一步推导出了该能量函数的快速闭式解,并表明该解可以用不到十行代码实现。

猫天意的博客 248

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 1117

HDU2095-find your present (2)

问题描述 find your present (2) Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/1024 K (Java/Others)Total Submission(s): 9613Acce...

chichengbu3180的博客 152

古风仙侠少女三视图提示词,一键生成角色设定

3D中国写实CG风格,CG渲染质感,精细3D建模,PBR物理材质,细腻服装纹理,电影级灯光,丰富表情,高精度场景,次世代引擎画质。平视正交视角,统一光照,纯白背景,无文字无水印,避免强透视和动态变形。3D中国写实CG风格,CG渲染质感,精细3D建模,PBR物理材质,细腻服装纹理,电影级灯光,丰富表情,高精度场景,次世代引擎画质。3D中国写实CG风格,CG渲染质感,精细3D建模,PBR物理材质,细腻服装纹理,电影级灯光,丰富表情,高精度场景,次世代引擎画质。少女,古风仙侠少女气质,灵动、温婉、仙气。

欢迎来到鸾姝淡月博客,专为程序员和编程爱好者打造的技术博客。我们分享编程语言趋势、开发工具、编程哲学、职业发展等,助你掌握新技术,优化技能,激发编程热情。 1058

HDU 2095 - find your present (2)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 23060    Accepted Submission(s): 9172 Problem Description In the new year party, e

Dilthey's Blog 419

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HDU 2095 Find your present (2)

题目链接 在拿到这道题的时候,想定义一个二维数组,第一维存数,第二维存出现的次数就完事了。结果发现,数据量非常大-.-,铁定超时。有没有接触过那些好用的模板库QAQ,思考了好久,还是没想出来,后来查阅了很多博主的博客,发现了个非常巧妙的做法,就是运用位异或 下面列出我们做题需要的性质 1、0^n = n。 2、n^n = 0。 而由题可得,我们需要的是为奇数的式子,(偶数的会被约去)所以我们只需将...

Roxannekkk的博客 203

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

hdu_2095 find your present (2)

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2095 分析:              可以看这里的分析。 我的代码: #include int main() { int n; while(~scanf("%d",&n),n) { int ans=0; for(int i=0;i<n;

徵羽調_xiao賤的专栏 804

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

HDU-2095 find your present (2)

find your present (2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 22091    Accepted Submission(s): 8734 Problem Description In the

MrQ_zh的博客 297

HDU2095find your present (2)

http://acm.hdu.edu.cn/showproblem.php?pid=2095 Problem Description In the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of pr

*乘号的笔记本 250

HDU 2095 find your present (2)( 位运算 )

链接:传送门 题意:给出n个数,这n个数中只有一种数出现奇数次,其他全部出现偶数次,让你找到奇数次这个数 思路:简单异或运算题 /************************************************************************* > File Name: hdu2095.cpp > Author: W...

dijingzhou4259的博客 122

hdu2095 find your present (2)(C语言

Problem Description In the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of presents now putting on the desk, and only one of them wil

sinat_39591298的博客 583

hdu2095 find your present(2)

find your present (2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19885    Accepted Submission(s): 7739 Problem Description In the

葡萄架的程序猿 383

hdu 2095 find your present(2)

find your present (2) Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/1024 K (Java/Others) Total Submission(s): 5186 Accepted Submission(s): 1513   Problem Des

逸疏 827

hdu2095 find your present (2)

/******************************************************* * Authoor:fisty * Data : 2014/10/1 * 异或hdu2095 * 除答案那些都是偶数个异或之后是0,异或满足交换律最后的就是答案 **************************************************/ #inc

fisty 450
上一篇: HDU 2091 空心三角形
下一篇: HDU 2094 产生冠军
New-Spirit
博客等级 码龄14年 13粉丝 138原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值