/*by SilverN*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
using namespace std;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL read1(){
LL x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int pri[mxn],cnt=;
bool vis[mxn];
void Pri(){
for(int i=;i<mxn;i++){
if(!vis[i])pri[++cnt]=i;
for(int j=;j<=cnt && pri[j]*i<mxn;j++){
vis[pri[j]*i]=;
if(i%pri[j]==)break;
}
}
return;
}
int T,n,m;
int a[][];
void solve(){
int i=,j=;
while(i<=m && j<n){
int p=i;
for(int k=i;k<=m;k++)
if(a[k][j]){p=k;break;}
if(a[p][j]){
if(p!=i){
for(int k=;k<=n;k++)
swap(a[i][k],a[p][k]);
}
for(int l=i+;l<=m;l++){
if(a[l][j]){
for(int c=i;c<=n;c++)
a[l][c]^=a[i][c];
}
}
i++;
}
j++;
}
LL ans=(1LL<<(n-i))-;
printf("%lld\n",ans);
return;
}
int main(){
int i,j;
Pri();
T=read();
LL x;
while(T--){
memset(a,,sizeof a);m=;
//
n=read();
for(i=;i<n;i++){
x=read1();
for(j=;i<=cnt && x>;j++){
if(x%pri[j]==){
m=max(m,j);//方程组数量
while(x%pri[j]==){
a[j-][i]^=;
x/=pri[j];
}
}
}
}
solve();
}
return ;
}

UVa11542 Square的更多相关文章

  1. UVA11542 Square(高斯消元 异或方程组)

    建立方程组消元,结果为2 ^(自由变元的个数) - 1 采用高斯消元求矩阵的秩 方法一: #include<cstdio> #include<iostream> #includ ...

  2. [LeetCode] Matchsticks to Square 火柴棍组成正方形

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...

  3. [LeetCode] Valid Word Square 验证单词平方

    Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...

  4. [LeetCode] Valid Perfect Square 检验完全平方数

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  5. [LeetCode] Maximal Square 最大正方形

    Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...

  6. OPEN CASCADE Gauss Least Square

    OPEN CASCADE Gauss Least Square eryar@163.com Abstract. The least square can be used to solve a set ...

  7. OpenCascade Eigenvalues and Eigenvectors of Square Matrix

    OpenCascade Eigenvalues and Eigenvectors of Square Matrix eryar@163.com Abstract. OpenCascade use th ...

  8. Leetcode: Matchsticks to Square && Grammar: reverse an primative array

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...

  9. Leetcode: Valid Word Square

    Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...

随机推荐

  1. MATLAB编程技巧

    [摘要] MATLAB是一种科学计算语言,和C.Fortran等高级语言相类似,能方便的实现程序控制.以下介绍一点matlab编程的技巧. 嵌套计算 程序执行的速度取决于调用的子程序的个数和算法实现. ...

  2. 【wqs二分】HHHOJ#15. 赤

    这个wqs二分并不熟练…… 题目描述 #15. 赤 题目分析 两维都用wqs二分,其他没有什么特殊之处. 重点在于,wqs二分还原最优解的时候,增量是强制给的k. #include<bits/s ...

  3. centos7重启后/etc/resolv.conf 被还原解决办法

    每次重启服务器后,/etc/resolv.conf文件就被自动还原了,最后发现是被Network Manager修改了. 查看Network Manager服务状态 systemctl status ...

  4. SQL_3_表达式、条件语句与运算

    加号的两种用法: 1.在SELECT子句中使用+号以执行对数据的运算并将结果显示出来. SELECT ITEM WHOLESALE WHOLESALE+0.15 FROM PRICE; 还可以重命名新 ...

  5. MFC 中 删除一个非空文件夹

    MFC中提供了删除文件夹的一个封装函数 RemoveDirectory(LPCTSTR lpPathName),我们只要把要删除的文件夹的路径传进去就可以删除了,貌似一切如此简单.我象征性的建立一个文 ...

  6. python for data analysis chapter1~2

    Q1:numpy与series的区别:index Tab补全(任意路径Tab) 内省(函数:?显示文档字符串,??显示源代码:结合通配符:np.* load *?) %load .py ctrl-c( ...

  7. js 常用判断

    JS三元运算符 三元运算符: 如名字表示的三元运算符需要三个操作数. 语法是 条件 ? 结果1 : 结果2;. 这里你把条件写在问号(?)的前面后面跟着用冒号(:)分隔的结果1和结果2.满足条件时结果 ...

  8. luogu3386 【模板】二分图匹配 匈牙利算法 hdu2063 过山车 dinic

    luogu 匈牙利算法 #include <iostream> #include <cstring> #include <cstdio> using namespa ...

  9. hexo博客出现“Cannot GET/xxxx”的错误

    最近在github上搭了一个hexo博客系统,非常轻量级的,只需要几句nodejs命令就搭建完成了.我了解了一下,hexo博客是基于nodejs写的,采用ejs模板引擎编写页面. 因为默认的主题风格不 ...

  10. python基础-爬虫

    爬虫引入 爬虫: 1 百度:搜索引擎 爬虫:spider   种子网站开始爬,下载网页,分析链接,作为待抓取的网页 分词 index:词--->某个结果 Page rank(1 网站很大(互链) ...