3 solutions

  • 0
    @ 2021-12-16 20:10:17
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n;
    	scanf("%d",&n);
    	long long num;
    	long long result=0;
    	for(int i =1;i<=n;i++){
    		scanf("%lld",&num);
    		result=result^num;
    	}
    	printf("%lld",result);
    	return 0;
    }
    
    • 0
      @ 2021-11-28 10:19:54
      #include<iostream>
      #include<cstdio>
      using namespace std;
      long long num[10000005];
      int cnt[10005];
      int main(void)
      {
      	int n;
      	long long x=0;
      	cin>>n;
      	for(int i=0;i<n;i++) scanf("%lld",&num[i]);
      	for(int i=0;i<n;i++) x^=num[i];
      	printf("%lld",x);
      	
      	return 0;
       } //用cin和cout会超时欸
      • 0
        @ 2021-11-28 9:35:59

        先了解一下位运算异或的知识:https://blog.csdn.net/qq_19272431/article/details/78564391 然后你就会做这个题了

        #include<stdio.h>
        typedef long long ll;
        int main(){
        	ll n,x,ans=0;
        	scanf("%lld",&n);
        	while(n--){
        		scanf("%lld",&x);
        		ans^=x;
        	}
        	printf("%lld",ans);
        	
        	return 0;
        }
        
        • 1

        Information

        ID
        185
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        8
        Tags
        # Submissions
        318
        Accepted
        37
        Uploaded By