hdu6085 手写bitset

#include
#include
#include
#include
#include
using namespace std;
typedef unsigned long long ull;
const int maxn=50005;
struct Bitset
{
    ull bit[1565];//开两倍的空间,50000/64*2
    void reset()
    {
        memset(bit,0,sizeof(bit));
    }
    void flip(int pos)
    {
        bit[pos>>6]^=(ull)1<<(pos&63);
    }
    bool judge(int pos)
    {
        return bit[pos>>6]&((ull)1<<(pos&63));
    }
}a,ans;
int b[maxn];
ull pre[64];
void init()
{
    pre[0]=1;
    for(int i=1;i<64;i++)
        pre[i]=pre[i-1]|((ull)1<>6,pos1=(j*b[i])&63,ind2=(j*b[i]+b[i]-1)>>6,pos2=(j*b[i]+b[i]-1)&63;//哈希
                ull temp;
                if(ind1==ind2)//分为三段
                {
                    temp=a.bit[ind1]>>pos1;
                    temp&=pre[pos2-pos1];
                    ans.bit[0]^=temp;
                }
                else
                {
                    int nowind=0,nowpos=63-pos1;
                    temp=a.bit[ind1]>>pos1;
                    temp&=pre[nowpos];
                    ans.bit[0]^=temp;
                    if(pos1==0)
                        for(int k=ind1+1;k>pos1;
                            temp&=pre[nowpos];
                            ans.bit[nowind]^=temp;
                        }
                    if(pos1==0)
                        ans.bit[++nowind]^=a.bit[ind2]&pre[pos2];
                    else if(pos2>pos1;
                        temp&=pre[pos2-pos1];
                        ans.bit[nowind]^=temp;
                    }
                }
            }
        }
        for(i=0;i

你可能感兴趣的:(hdu6085 手写bitset)