• HDU 5833 Zhu and 772002 ——线性基


    【题目分析】

        这题貌似在UVA上做过,高精度高斯消元。

        练习赛T2,然后突然脑洞出来一个用Bitset的方法。

        发现代码只需要30多行就A掉了

        Bitset大法好

    【代码】

    #include <cstdio>
    #include <bitset>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    #define F(i,j,k) for (int i=j;i<=k;++i)
    #define D(i,j,k) for (int i=j;i>=k;--i)
    #define ll long long
    #define maxn 2005
    const int md=1000000007;
    int pr[maxn],ispr[maxn],top=0;
    bitset <505> lb[505],now;
    int main()
    {
        F(i,2,maxn-1)
        {
            if (!ispr[i]) pr[++top]=i;
            for (int j=1;j<=top&&pr[j]*i<maxn;++j)
            {
                if (i%pr[j]==0) {ispr[i*pr[j]]=1; break;}
                ispr[i*pr[j]]=1;
            }
        }
        int t,n,cnt;ll x;
        scanf("%d",&t);
        int kas=0;
        while (t--)
        {
            printf("Case #%d:
    ",++kas);
            cnt=0;
            F(i,0,504) lb[i].reset();
            scanf("%d",&n);
            F(i,1,n)
            {
                scanf("%lld",&x);
                now.reset();
                F(i,1,top)
                {
                    int flag=0;
                    while (x%pr[i]==0) x/=pr[i],flag^=1;
                    now[i]=flag;
                }
                int tag=1;
                D(j,500,1)
                    if (now[j])
                    {
                        if (lb[j].count()==0) {lb[j]=now;tag=0;break;}
                        else now^=lb[j];
                    }
                cnt+=tag;
            }
            ll ans=1;
            while (cnt)
            {
                ans<<=1;
                ans%=md;
                cnt--;
            }
            printf("%lld
    ",(ans-1+md)%md);
        }
    }
    

      

  • 相关阅读:
    144.二叉树的前序遍历
    103.二叉树的锯齿形层次遍历
    shiro系列二、身份验证和授权
    shiro系列一、认识shiro
    发送短信——java
    redis系列二: linux下安装redis
    redis系列一: windows下安装redis
    BootstrapValidator 表单验证超详细教程
    Linux ps 命令详解
    Vmvare 虚拟机固定IP
  • 原文地址:https://www.cnblogs.com/SfailSth/p/6435403.html
Copyright © 2020-2023  润新知