# 「雅礼集训 2017 Day5」矩阵

## 60pts

1）$j$、$k$都不变，即新的一列在$j+k$个基里面，方案为$2^{j+k}$

2）$j+1$、$k$不变，$k$不变的方案有$2^{r+k}$，再减去$j$不变的方案就是$2^{r+k}-2^{j+k}$

3）$j$不变，$k+1$，总方案有$2^n$，再减去$k$不变的方案就是$2^n-2^{r+k}$

## 100pts

30pts时说到，秩相同的$C$的答案都是一样的

18.12.26 update:

## Code

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#define LL long long
using namespace std;
const LL Maxn = 2010;
const LL Mod = 1e9+7;
bitset <Maxn> a[Maxn];
LL f[Maxn][Maxn];
LL pow2[Maxn], n;
LL pow(LL x, LL k) {
LL ret = 1;
while(k){
if(k&1) ret = (ret*x)%Mod;
x = (x*x)%Mod;
k >>= 1;
}
return ret;
}
int main() {
//freopen("mat.in", "r", stdin);
//freopen("mat.out", "w", stdout);
LL i, j, k;
scanf("%lld", &n);
pow2[0] = 1;
for(i = 1; i <= n; i++) pow2[i] = (pow2[i-1] << 1) % Mod;
f[0][0] = 1;
for(i = 0; i < n; i++){
for(j = 0; j <= i; j++){
if(f[i][j] == 0) continue;
f[i+1][j] = (f[i+1][j] + (f[i][j]*pow2[j])%Mod) % Mod;
f[i+1][j+1] = (f[i+1][j+1] + (f[i][j]*((pow2[n]-pow2[j]+Mod)%Mod))%Mod) % Mod;
}
}
for(i = 0; i < n; i++){
for(j = 0; j < n; j++){
LL x;
scanf("%lld", &x);
a[i][j] = x;
}
}
LL r = 0;
for(i = 0; i < n; i++){
for(j = r; j <= n; j++){
if(a[j][i] == 1){ swap(a[r], a[j]); break; }
}
if(a[r][i] == 0) continue;
for(j = r+1; j < n; j++) if(a[j][i] == 1) a[j] ^= a[r];
r++;
}
LL ans = 0;
for(i = r; i <= n; i++){
ans = (ans + ((f[n][i]*f[i][r])%Mod*pow(pow2[n], n-i))%Mod)%Mod;
}
ans = (ans*pow(f[n][r], Mod-2))%Mod;
printf("%lld\n", ans);
return 0;
}


posted @ 2017-12-19 09:08 Ra1nbow 阅读(...) 评论(...) 编辑 收藏