当前位置:网站首页>[51nod p2106] an odd number of times [bit operation]

[51nod p2106] an odd number of times [bit operation]

2022-06-13 09:35:00 Ayane.

 Insert picture description here
l i n k link link

analysis :

Exclusive or
A number occurs an even number of times Their XOR value is 0 0 0 Otherwise, this number

CODE:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define reg register
using namespace std;
typedef long long ll;
int n,x,ans; 
int main(){
    
	scanf("%d",&n);
	while(n--)
	{
    
		scanf("%d",&x);
		ans^=x;
	}
	printf("%d",ans);
	return 0;
}
原网站

版权声明
本文为[Ayane.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270530324413.html