3295 questions about algorithms in chapter 9 and chapter 9
Time Limit: 1 s space limit: 1000 KB title level: GoldQuestionView running resultsDescriptionDescription
There are n numbers (n is an odd number), n-1 numbers are paired in pairs, and one number is placed on a single order to find this number. Requires the time complexity of O (n) and the space complexity of O (1 ).
Input description
Input Description
Enter n in the first line. n is an odd number greater than or equal to 1.
The second row contains n integers.
Output description
Output Description
Number of orders output
Sample Input
Sample Input
3
1 7 1
Sample output
Sample Output
7
Data range and prompt
Data Size & Hint
1 <= n <= 4000001 n is an odd number
CATEGORY tag
Tags click here to expand
For any x,
Has the following properties:
X ^ y = x;
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define lli long long int 6 using namespace std; 7 int main() 8 { 9 int n;10 cin>>n;11 n--;12 int now,x;13 cin>>now;14 while(n--)15 {16 scanf("%d",&x);17 now^=x;18 }19 cout<<now;20 return 0;21 }