zoukankan      html  css  js  c++  java
  • hdu-5650 so easy(水题)

    题目链接:

    so easy

    Time Limit: 2000/1000 MS (Java/Others)  

    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 138    Accepted Submission(s): 110


    Problem Description
    Given an array with
    n
    integers, assume f(S) as the result of executing xor operation among all the elements of set S. e.g. if S={1,2,3} then f(S)=0.

    your task is: calculate xor of all f(s), here sS.
     
    Input
    This problem has multi test cases. First line contains a single integer T(T20) which represents the number of test cases.
    For each test case, the first line contains a single integer number n(1n1,000) that represents the size of the given set. then the following line consists of ndifferent integer numbers indicate elements(109) of the given set.
     
    Output
    For each test case, print a single integer as the answer.
     
    Sample Input
    1
    3
    1 2 3
     
    Sample Output
    0
    In the sample,$S = {1, 2, 3}$, subsets of $S$ are: $varnothing$, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}
    题意:问一个集合的所有子集合的异或和的异或和;
    思路:因为a^a=0;所以就看代码;
    AC代码:
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    const long long mod=1e9+7;
    int main()
    {
    
        int t,n,a[1004];
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&n);
            for(int i=1;i<=n;i++)
            {
                scanf("%d",&a[i]);
            }
            if(n==1)
            {
                cout<<a[1]<<"
    ";
            }
            else cout<<"0"<<"
    ";
        }
        return 0;
    }
  • 相关阅读:
    P4365 [九省联考2018]秘密袭击coat
    P3705 [SDOI2017]新生舞会 01分数规划+费用流
    P4313 文理分科 最小割
    P1707 刷题比赛
    P3994 高速公路 树形DP+斜率优化+二分
    P3384 【模板】树链剖分
    P4915 帕秋莉的魔导书
    P3690 【模板】Link Cut Tree (动态树)
    P3615 如厕计划
    loj #2538. 「PKUWC2018」Slay the Spire
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5324540.html
Copyright © 2011-2022 走看看