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;
    }
  • 相关阅读:
    Intellij IDEA debug jar包
    diamond简介和使用
    dubbo配置指南
    dubbo简单配置与使用
    设计模式之策略模式
    悲观锁和乐观锁
    sql建表,建索引注意事项
    jvm 调优(2)垃圾回收算法
    jvm 调优(1)概念
    jvm 命令
  • 原文地址:https://www.cnblogs.com/RootVount/p/10284400.html
Copyright © 2011-2022 走看看