T1:

7.24考试

7.24考试

真.题面

7.24考试

时空限制:7.24考试

看到时空限制,就知道这是一个脑洞题

我们联想异或运算:相同为0,不同为1

所以我们可以把所有的数异或起来,最后的数就是答案

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{
    char ch=getchar();
    int x=0;bool f=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<3)+(x<<1)+(ch^48);
        ch=getchar();
    }
    return f?-x:x;
}
int n,x,a;
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
    {
       x=read();
       a^=x;
    }
    printf("%d",a);
}
T1

相关文章:

  • 2021-11-29
  • 2021-08-01
  • 2022-12-23
  • 2021-04-29
  • 2021-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-07-24
猜你喜欢
  • 2022-02-08
  • 2021-12-15
  • 2022-12-23
  • 2021-12-14
  • 2021-05-12
  • 2021-12-23
  • 2022-01-11
相关资源
相似解决方案