# HDU-5833-Zhu and 772002【2016CCPC网络赛】【高斯消元】

## 1002-Zhu and 772002

Problem Description
Zhu and 772002 are both good at math. One day, Zhu wants to test the ability of 772002, so he asks 772002 to solve a math problem.

But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.

There are n numbers a1,a2,…,an. The value of the prime factors of each number does not exceed 2000, you can choose at least one number and multiply them, then you can get a number b.

How many different ways of choices can make b is a perfect square number. The answer maybe too large, so you should output the answer modulo by 1000000007.

Input
First line is a positive integer T , represents there are T test cases.

For each test case:

First line includes a number n(1≤n≤300)，next line there are n numbers a1,a2,…,an,(1≤ai≤1018).

Output
For the i-th test case , first output Case #i: in a single line.

Then output the answer of i-th test case modulo by 1000000007.

Sample Input
2
3
3 3 4
3
2 2 2

Sample Output
Case #1:
3
Case #2:
3

ans=2^num-1(去掉全部为0)


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
#define maxn 2100
ll vis[maxn];
ll prime[maxn]={0};
ll a[maxn];
ll fc[maxn][maxn]={{0}};
int n;
int pnum;
int get_primes(int m) {
memset(vis, 0, sizeof(vis));
int cnt = 1; //注意
for (int i = 2; i < m; i++) {
if (!vis[i]) {
prime[cnt++] = i;
for (int j = i * i; j < m; j += i)
vis[j] = 1;
}
}
return cnt;
}
void change(ll k,ll g)
{
for(int i = 1; i <= pnum; )
{
if(k % prime[i] == 0)
{
fc[i][g] ^= 1;
k /= prime[i];
}
else i++;
}
return;
}
ll gauss()
{
ll g = 0;
int i,j;
for(j = 1; j <= n && g < pnum; j++)
{
for(i = g + 1; i <= pnum; i++)
if(fc[i][j] == 1)
break;
if(i <= pnum)
{
g++;
for(int p = j; p <= n; p++)
swap(fc[g][p],fc[i][p]);
for(int p = g + 1; p <= pnum; p++)
{
if(fc[p][j] == 1)
{
for(int q = j; q <= n; q++)
fc[p][q] ^= fc[g][q];
}
}
}
}
return g;
}
ll qpow(ll a,ll b,ll m)
{
ll ans = 1;
while(b){
if(b & 1){
ans = (ans * a) % m;
b--;
}
b /= 2;
a = a * a % m;
}
return ans;
}
int main(){
int cas = 1;
int t;
cin >> t;
get_primes(2100);
pnum = 303;
while(t--)
{
memset(fc,0,sizeof(fc));
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i],change(a[i],i);

int r = gauss();  //求变元个数

ll ans = qpow(2, (ll)(n - r), mod) - 1;
printf("Case #%d:\n%lld\n",cas++,ans);
}
}

举报原因： 您举报文章：HDU-5833-Zhu and 772002【2016CCPC网络赛】【高斯消元】 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)