find your present (2)

本文介绍了一个通过位运算找出唯一奇数次出现的礼物编号的算法。该算法适用于一系列礼物编号中仅有一个编号出现奇数次的情况。输入为一组整数,输出即为所求的特殊礼物编号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                   find your present (2)

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

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
HDU 2007-Spring Programming Contest - Warm Up (1)

Recommend
8600

位运算的巧妙运用!

#include<stdio.h>
int main
()
{

   int
i,k,n,s;
   while
(scanf("%d",&n),n)
   {

   s=0;
    for
(i=0;i<n;i++)
{

  scanf("%d",&k);
  s^=k;
}

   printf("%d\n",s);
   }
}

</div></span> <!--<span class="menuTitle">Detail</span>--> </div> <div style="clear: both;font-size: 12px"> <span id="span5433555"><a style="cursor: pointer" onclick="saveLibrary('5433555')" name="0">保存</a></span>   <span class="relative"><a style="cursor: pointer" target="blank" href="//www.oalib.com//relative/5433555">相关文章</a></span> </div> <a name="saveVal" id="0-5433555"></a> </td> </tr> </table> </td> </tr> <tr align="left"> <td colspan="3"> <table border="0" cellpadding="0" cellspacing="0" width="720px" style="line-height: 23px;" align="center"> <tr> <td style="padding: 10px 0 10px 5px; border-bottom: solid 1px #c0c0c0; font-size: 14px;width: 720px"> <!-- <input type="checkbox" name="checkId" value="6326548" /> --> <span style="font-size: 16px;" ><a href="//www.oalib.com/paper/6326548" target="_blank" style="font-weight: bold;"><u><b><font color="#DD4B39">区块</font></b><b><font color="#DD4B39">链</font></b>的主要应用<br>The Main Application of Block Chain</u></a> <a target="_blank" href="http://www.hanspub.org/journal/PaperDownload.aspx?paperID=39373"> [PDF]</a> </span> <br /> <span class="authorLimit" style="font-size:13px"><a href="http://www.oalib.com:80/search?kw=鲍超群&searchField=authors">鲍超群</a>,<a href="http://www.oalib.com:80/search?kw= 张毅&searchField=authors"> 张毅</a></span> <br/> <a href="//www.oalib.com/journal/1109/1" target="_blank"> <u>Computer Science and Application (CSA)</u> </a>, 2020, DOI: <span>10.12677/CSA.2020.1012241</span> <br /> <div> <span class="menuContent"><b>Abstract</b>: <div style=\"text-align:justify;\"> <span style=\"font-size:14px;\">当今社会,大数据时代各类信息发展迅速,其中<b><font color="#DD4B39">区块</font></b><b><font color="#DD4B39">链</font></b>的发展尤为重要,因其具有着去中心化性、透明性、开放性、数据不可修改、可追溯性被广泛应用于各领域。本文主要对<b><font color="#DD4B39">区块</font></b><b><font color="#DD4B39">链</font></b>在教育、金融、医疗、农业领域方面应用做出论述,对现阶段<b><font color="#DD4B39">区块</font></b><b><font color="#DD4B39">链</font></b>技术发展面对的挑战进行分析。<br /> In today’s society, all kinds of information in big data era are developing rapidly, among which the development of block chain is particularly important. Because of its decentralization, transparency, openness, data immutability and traceability, it is widely used in various fields. This paper mainly discusses the application of blockchain in the fields of education, finance, medical treatment and agriculture, and analyzes the challenges faced by the development of blockchain technology at the present stage.</span>。我想通过BeautifulSoup语法提取出上述源码中的,标题,作者等信息,该怎么写,请使用soup.find语法,
最新发布
06-15
<br>    第(1/3)页<br><br>    夕阳西下,霞光漫天。 <br><br>    风火城外,翠云峰上,有一张石桌,桌旁,有石凳,一对少年男女相互依偎。 <br><br>    少年身材偏瘦,脸色略显苍白,面庞清秀。 <br><br>    少女一席雪白长裙,肌肤如玉,容貌绝美。 <br><br>    少女脑袋靠在少年的肩膀上,在夕阳的照射下,宛如一对神仙眷侣。 <br><br>    “瑶儿,真希望能一辈子如此!”少年脸上满是幸福的笑容,轻轻说道。 <br><br>    “鸣哥哥,当然可以了,我们可是说过要一生一世在一起的。” <br><br>    少女脸上露出幸福的笑容。 <br><br>    少年名为陆鸣,少女名为陆瑶。 <br><br>    看着陆瑶脸上的笑容,陆鸣眼神更是温柔,握住陆瑶柔弱无骨的玉手,道:“瑶儿,我虽然筋脉堵塞,不能凝练真气,但只要我能觉醒血脉,到时长老院就会购买灵药,为我疏通经脉,那我就可以修炼了。” <br><br>    “我一定会成为一个武道强者,守护你一生一世的。” <br><br>    “谢谢鸣哥哥。” <br><br>    陆瑶眼中露出感动之色,又道:“鸣哥哥,曾经真的有测脉者测过,你遗传了你父亲的血脉吗?” <br><br>    “是啊,瑶儿,所以将来你的男人,一定会是一个强者。”陆鸣脸上露出自信的笑容。 <br><br>    陆瑶微微一笑,端起石桌上的酒杯,酒杯中,是著名的血舌兰花酒,散发出淡淡的清香。 <br>用re匹配文字
04-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值