杭电2095(find your present (2))

简介: 杭电2095(find your present (2))


  • 引用块内容

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

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

题目总结:

此题题意不明 如果按上面代码的话

意思是找出数据中特殊的数也即是出现次数最少的数据 这里用到了异或

异或详解

#include<stdio.h>
int main()
{
    int n;
    while(~scanf("%d",&n)&&n)
    {
        int m,max=-0x3f3f3f3f;
        while(n--)
        {
            scanf("%d",&m);
            if(m>max)
              max=m;
        }
        printf("%d\n",max);
    }
    return 0;
}


目录
相关文章
|
4月前
|
搜索推荐 Docker 容器
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
执行 `DimPlot` 函数时遇到错误 `;Error in Ops. data. frame(g guides_loc, panel_loc) : &#39;==&#39; only defined for equally-sized data frames`。解决方案和办法
1204 0
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
|
机器学习/深度学习 NoSQL Linux
攻防世界-Reverse新手区WP--no-strings-attached
攻防世界-Reverse新手区WP--no-strings-attached
65 0
【hacker的错误集】DeprecationWarning: find_element_by_* commands are deprecated.
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead。依旧是使用单词意思分析报错原因
150 0
【hacker的错误集】DeprecationWarning: find_element_by_* commands are deprecated.
|
机器学习/深度学习 Java
HDOJ 2095 find your present (2)
HDOJ 2095 find your present (2)
112 0
HDOJ 2095 find your present (2)
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
117 0
【愚公系列】2021年11月 攻防世界-简单题-MISC-004(give_you_flag)
【愚公系列】2021年11月 攻防世界-简单题-MISC-004(give_you_flag)
137 0
【愚公系列】2021年11月 攻防世界-简单题-MISC-004(give_you_flag)
|
Web App开发 Java 数据安全/隐私保护
HDOJ(HDU) 1563 Find your present!(异或)
HDOJ(HDU) 1563 Find your present!(异或)
241 0
HDOJ 1096 A+B for Input-Output Practice (VIII)
HDOJ 1096 A+B for Input-Output Practice (VIII)
108 0
HDOJ 1095 A+B for Input-Output Practice (VII)
HDOJ 1095 A+B for Input-Output Practice (VII)
111 0
转:肉饼的自白:You&#39;ve got to find what you love
《You've got to find what you love》是乔布斯2005年在斯坦福大学毕业典礼上的演讲,当我第一次看到这个演讲视频的时候,被彻底震住了。回顾自己跌跌撞撞的人生道路,就是一个不断寻找然后坚持自己钟爱事业的过程。
1376 0
下一篇
DataWorks