忘了求素因子数目还有个判断 x>1时,素因子数目+1
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define INF 1e9
#define maxn 60
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define mset(x) memset(x,0,sizeof(x))
int kase,n,m;
int main(){
// freopen("a.txt","r",stdin);
// freopen(".out","w",stdout);
cin>>kase;
rep(ks,1,kase){
cin>>n>>m;
int tmp, x, res=0;
rep(i,1,n){
x=0;
rep(j,1,m){
cin>>tmp;
for(int k=2;k<=sqrt(tmp+0.5);k++)
while(tmp%k==0){
tmp/=k;
x++;
}
if(tmp>1)
x++;
}
res ^= x;
}
printf("Case #%d: ",ks);
if(res)
puts("YES");
else puts("NO");
}
return 0;
}
/*
DESCRIPTION:
选择一行的几个数,对每一个数,除以它的某个因子
先让矩阵的每个数都是1的一方赢
把一个数分成几个素因子之积
12 = { 2, 2, 3 };
6 = { 2, 3 }
矩阵的一行( 6, 12 ),要选择几个数,并除以他们的因子,就相当于拿走几个素因子
可以把每一行都看做一个石堆,每次在一堆中拿走任意石子
接着就可以用sg函数,nim和为0则先手输
*/