zoukankan      html  css  js  c++  java
  • SDNU 1541.Your Code Is Awesome

    Description

    There is an ACMer named The_Flash, who can write g♂♂d code in SDNU ACM Traing Team. With his excellent coding skills, he has won a lot of praises.

    Now, he gives you an easy problem to solve, the problem is showen as follows.

    Give you a sequence with integers, it is guaranteed that only two different integers appear once and other integers are all appear twice. You are expected to find out that two "single" integers.

    Input

    The first line is an integer T(), denoting the number of testcases.

    For each testcase, there is an integer , then following integers , there is a space between every two integers.

    Output

    For each testcase, output two integer, denoting the answer. (In order from small to large).

    Sample Input

    2
    2
    1 2
    10
    1 1 2 2 3 3 4 4 6 5

    Sample Output

    1 2
    5 6
    #include <cstdio>
    #include <iostream>
    using namespace std;
    int a[1000000+8];
    int main()
    {
        int t, n, f, sum, x, y;
        scanf("%d", &t);
        for(int i=0; i<t; i++)
        {
            scanf("%d", &n);
            sum=0;
            for(int j=0; j<n; j++)
            {
                scanf("%d", &a[j]);
                sum ^= a[j];
            }
            f=1;
            while(!(f&sum))
            {
                f <<= 1;
            }
            x=y=0;
            for(int j=0; j<n; j++)
            {
                if(f&a[j]) x ^= a[j];
                else y ^= a[j];
            }
            if(x>y)
            {
                int r=x;
                x=y;
                y=r;
            }
            printf("%d %d
    ", x, y);
        }
        return 0;
    }
  • 相关阅读:
    springboot02-SpringSecurity
    java基础07- 二维数组
    java基础06-数组的使用
    逆向工程核心原理——第四章
    逆向工程核心原理——第三章
    Crackme_1_Acid_burn
    Crackme_2_Afkayas.1
    逆向工程核心原理——第二章
    MessageBox
    Python(基础)
  • 原文地址:https://www.cnblogs.com/RootVount/p/10284400.html
Copyright © 2011-2022 走看看