• A. XOR Mixup


    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    There is an array aa with n−1n−1 integers. Let xx be the bitwise XOR of all elements of the array. The number xx is added to the end of the array aa (now it has length nn), and then the elements are shuffled.

    You are given the newly formed array aa. What is xx? If there are multiple possible values of xx, you can output any of them.

    Input

    The input consists of multiple test cases. The first line contains an integer tt (1≤t≤10001≤t≤1000) — the number of test cases. The description of the test cases follows.

    The first line of each test case contains an integer nn (2≤n≤1002≤n≤100) — the number of integers in the resulting array aa.

    The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤1270≤ai≤127) — the elements of the newly formed array aa.

    Additional constraint on the input: the array aa is made by the process described in the statement; that is, some value of xx exists.

    Output

    For each test case, output a single integer — the value of xx, as described in the statement. If there are multiple possible values of xx, output any of them.

    Example

    input

    Copy

     
    

    4

    4

    4 3 2 5

    5

    6 1 10 7 10

    6

    6 6 6 6 6 6

    3

    100 100 0

    output

    Copy

    3
    7
    6
    0
    

    Note

    In the first test case, one possible array aa is a=[2,5,4]a=[2,5,4]. Then x=2⊕5⊕4=3x=2⊕5⊕4=3 (⊕⊕ denotes the bitwise XOR), so the new array is [2,5,4,3][2,5,4,3]. Afterwards, the array is shuffled to form [4,3,2,5][4,3,2,5].

    In the second test case, one possible array aa is a=[1,10,6,10]a=[1,10,6,10]. Then x=1⊕10⊕6⊕10=7x=1⊕10⊕6⊕10=7, so the new array is [1,10,6,10,7][1,10,6,10,7]. Afterwards, the array is shuffled to form [6,1,10,7,10][6,1,10,7,10].

    In the third test case, all elements of the array are equal to 66, so x=6x=6.

    In the fourth test case, one possible array aa is a=[100,100]a=[100,100]. Then x=100⊕100=0x=100⊕100=0, so the new array is [100,100,0][100,100,0]. Afterwards, the array is shuffled to form [100,100,0][100,100,0]. (Note that after the shuffle, the array can remain the same.)

    解题说明:此题找规律就能发现输出任意一个数即可。

    1. #include
    2. int main()
    3. {
    4. int t, n;
    5. scanf("%d", &t);
    6. while (t--)
    7. {
    8. scanf("%d", &n);
    9. int a[105], i;;
    10. for (i = 0; i
    11. {
    12. scanf("%d", &a[i]);
    13. }
    14. printf("%d\n", a[n - 1]);
    15. }
    16. return 0;
    17. }

  • 相关阅读:
    vue - Vue脚手架/消息订阅与发布
    搞懂三极管
    进程间通信的方式
    系统分析师1:计算机系统基础
    JavaScript进阶内容——DOM详解
    多个方法多个出路!Microsoft Excel中合并单元格的8种方法
    代码随想录算法训练营第38天—动态规划06 | ● 完全背包 ● *518. 零钱兑换 II ● 377. 组合总和 Ⅳ
    数据库原理及应用实验报告-实验4-SQL的视图
    完成虚拟机环境配置,还有安装kettle
    避开大坑:win10-CPU版(64位)环境下安装Anaconoda和tensorflow,亲测成功
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/126336243