3295 questions about algorithms in chapter 9 and chapter 9

Source: Internet
Author: User

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 }

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.