UVa11542 Square
/*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的更多相关文章
- UVA11542 Square(高斯消元 异或方程组)
建立方程组消元,结果为2 ^(自由变元的个数) - 1 采用高斯消元求矩阵的秩 方法一: #include<cstdio> #include<iostream> #includ ...
- [LeetCode] Matchsticks to Square 火柴棍组成正方形
Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...
- [LeetCode] Valid Word Square 验证单词平方
Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...
- [LeetCode] Valid Perfect Square 检验完全平方数
Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...
- [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 ...
- OPEN CASCADE Gauss Least Square
OPEN CASCADE Gauss Least Square eryar@163.com Abstract. The least square can be used to solve a set ...
- OpenCascade Eigenvalues and Eigenvectors of Square Matrix
OpenCascade Eigenvalues and Eigenvectors of Square Matrix eryar@163.com Abstract. OpenCascade use th ...
- 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 ...
- Leetcode: Valid Word Square
Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...
随机推荐
- extranuclear gene|non-Mendelian inheritance|uniparental inheritance|maternal inheritance
5.8某些细胞器含有DNA 因为除细胞核内的染色体外,细胞质中的细胞器上也有遗传物质(这类遗传物质被称为核外基因(extranuclear gene),比如线粒体上的rRNA,这是因为细胞器基因组是独 ...
- java基础—数组
一.数组的基本概念 数组可以看成是多个相同类型数据组合,对这些数据的统一管理. 数组变量属引用类型,数组也可以看成是对象,数组中的每个元素相当于该对象的成员变量. 数组的元素可以是任何数据类型,包括基 ...
- Linux运维笔记--第四部
第四部 3. Linux扩展正则表达式实战 扩展的正则表达式:ERE(主要用于egrep或grep -E) + 重复一个或一个以上前面的字符. (*是0或多个) ? 重复0个或一个 ...
- 更改BootStrap popover的默认样式
.popover { position: absolute; top: 0; left: 0; z-index: 1060; display: none; max-width: 276px; padd ...
- 安装cfssl证书生成工具
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 wget https://pkg.cfssl.org/R1.2/cfssljson_linux-am ...
- centos7 killall 命令
centos7精简安装后,使用中发现没有killall命令. 安装这个包即可: yum install psmisc
- 搭建基于金山快盘的Git服务器
最近迷上了Git,这货堪称神器,用了它就再也不想用其他VCS了,就像上了高速就不想再走国道一样. 一般人使用Git+Github来搭建进行本地远程交互,不过Github弄个私人仓库是要刀乐思的,如果你 ...
- day04 装饰器 迭代器&生成器 Json & pickle 数据序列化 内置函数
回顾下上次的内容 转码过程: 先decode 为 Unicode(万国码 ) 然后encode 成需要的格式 3.0 默认是Unicode 不是UTF-8 所以不需要指定 如果非要转为U ...
- hibernate源码分析1-保存一个对象
要点 用了event的方式贯穿CRUD的过程 值得学习 用dynamic-insert 支持 插入时 可选 全字段插入 还是仅仅有值的字段插入. 返回主键的值 用了 Serializable 类型作为 ...
- JAVA-STRUTS-2x的项目配置
首先是web.xml的配置,这个是项目加载的开始. <display-name></display-name> <!--struts2配置开始--> <fil ...