zoukankan      html  css  js  c++  java
  • bzoj3687 简单题

    Description

    小呆开始研究集合论了,他提出了关于一个数集四个问题:
    1.子集的异或和的算术和。
    2.子集的异或和的异或和。
    3.子集的算术和的算术和。
    4.子集的算术和的异或和。
        目前为止,小呆已经解决了前三个问题,还剩下最后一个问题还没有解决,他决定把
    这个问题交给你,未来的集训队队员来实现。

    Input

    第一行,一个整数n。
    第二行,n个正整数,表示01,a2….,。

    Output

     一行,包含一个整数,表示所有子集和的异或和。

    Sample Input

    2
    1 3

    Sample Output

    6

    HINT

    【样例解释】

      6=1 异或 3 异或 (1+3)

    【数据规模与约定】

    ai >0,1<n<1000,∑ai≤2000000。

    另外,不保证集合中的数满足互异性,即有可能出现Ai= Aj且i不等于J

     
    bitset裸的应用,当时没有打,现在补上
    //Serene
    #include<algorithm>
    #include<iostream>
    #include<cstring>
    #include<cstdlib>
    #include<cstdio>
    #include<cmath>
    #include<bitset>
    using namespace std;
    const int maxn=2e6+10;
    int n,ans;
    bitset<maxn> G;
     
    int main() {
        scanf("%d",&n); int x;
        G[0]=1;
        for(int i=1;i<=n;++i) {
            scanf("%d",&x);
            G^=(G<<x);
        }
        for(int i=0;i<=2e6;++i) if(G[i]) ans^=i;
        cout<<ans;
        return 0;
    }
    

      

    弱者就是会被欺负呀
  • 相关阅读:
    [Js]面向对象基础
    [css]邮件的写法
    [Js]碰撞运动
    [Js]弹性运动
    [Js]布局转换
    [Js]高级运动
    [js]多个物体的运动
    [Js]缓冲运动
    外部 Storage Provider【转】
    hostPath Volume【转】
  • 原文地址:https://www.cnblogs.com/Serene-shixinyi/p/7568746.html
Copyright © 2011-2022 走看看