HDU5088

对于每个数,把它看做0和1组成的行,n个数就是n行,判断形成的矩阵中【秩】是否等于【n】

#include<iostream>
#include<cstdio>
using namespace std;
const int NO=1005;
long long s[65][NO];
long long p[NO];
int GET(long long k)
{
    int ans=0;
    while(k)
    {
        k>>=1;
        ans++;
    }
    return ans;
}
int main()
{
    freopen("1.txt","r",stdin);
    int ttt,n;
    scanf("%d",&ttt);
    while(ttt--)
    {
        for(int i=0;i<=64;i++)
            s[i][0]=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%I64d",&p[i]);
            int kkk=GET(p[i]&-p[i]);
            s[kkk][++s[kkk][0]]=p[i];
        }
        if(n>40)
        {
            puts("Yes");
            continue;
        }
        int num=0;
        for(int i=1;i<=64;i++)
            if(s[i][0])
            {
                for(int j=2;j<=s[i][0];j++)
                {
                    long long k=s[i][1]^s[i][j];
                    int kkk=GET(k&-k);
                    s[kkk][++s[kkk][0]]=k;
                }
                num++;
            }
        puts(num==n?"No":"Yes");
    }
    return 0;
}

时间: 2024-08-05 15:18:29

HDU5088的相关文章

HDU5088——Revenge of Nim II(高斯消元&amp;矩阵的秩)(BestCoder Round #16)

Revenge of Nim II Problem DescriptionNim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided th

HDU5088(高斯消元)

Revenge of Nim II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 443    Accepted Submission(s): 157 Problem Description Nim is a mathematical game of strategy in which two players take turns r