高斯消元&线性基模板
来源:互联网 发布:好听的翻唱知乎 编辑:程序博客网 时间:2024/05/21 08:46
高斯消元:poj1222
#include <iostream>#include <cstdio>#define N 5#define M 6#define L 10using namespace std;int n,b[L*L],a[L*L][L*L],c[L*L];inline int read(){int s=0; char c=getchar();while (c<'0' || c>'9') c=getchar();while (c>='0' && c<='9') s=s*10+c-'0',c=getchar();return s;}inline void mod(int x,int y){for (int i=1;i<=N*M;i++)a[x][i]^=a[y][i];b[x]^=b[y];}int main(){n=read();for (int t=1;t<=n;t++){for (int i=1;i<=N;i++)for (int j=1;j<=M;j++)b[M*(i-1)+j]=read();for (int i=1;i<=N;i++)for (int j=1;j<=M;j++){int x=M*(i-1)+j;a[x][x]=1;if (i>1) a[x][x-M]=1;if (i<N) a[x][x+M]=1;if (j>1) a[x][x-1]=1;if (j<M) a[x][x+1]=1;}for (int i=1;i<=N*M;i++){for (int j=i;j<=N*M;j++)if (a[j][i]){for (int k=1;k<=N*M;k++)swap(a[j][k],a[i][k]);swap(b[j],b[i]);}for (int k=1;k<=N*M;k++)if (a[k][i] && k!=i) mod(k,i);}printf("PUZZLE #%d\n",t);for (int i=1;i<=N;i++){for (int j=1;j<M;j++)printf("%d ",b[M*(i-1)+j]);printf("%d\n",b[M*i]);}}return 0;}
线性基:bzoj3150
#include <bits/stdc++.h>#define N 110#define ll long longusing namespace std;int n,a[N],c[N],l(-1),z[N],x;ll ans(0);int main(){scanf("%d",&n);for (int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+1+n);for (int i=n;i;i--){x=a[i];for (int j=0;j<=32;j++)if ((1<<j)&a[i]){if (c[j]) a[i]^=c[j];else{c[j]=a[i]; break;}}if (!a[i]) ans+=x;}printf("%lld\n",ans);return 0;}
0 0
- 高斯消元&线性基模板
- [模板]线性基
- sgu275 线性基模板题
- 线性基 模板 bzoj2460 【BeiJing2011】 元素
- 模板链式线性表
- 线性筛选素数模板
- 线性筛素数模板
- 线性筛模板
- 线性筛模板
- 线性筛模板
- 线性素数筛模板
- 【模板】线性筛素数
- [模板]线性筛素数
- 【模板】线性筛素数
- luogu3383 线性筛模板
- 线性筛素数模板
- [高斯消元与线性基]
- 模板线性栈和队列
- 设置ScrollView 里面的布局高度为match_parent不起作用
- swift3.0 闭包
- 蓝桥杯——计算机研究生机试真题(2017.2.16)
- MySQL-聚集函数(汇总)
- 401. Binary Watch | 二进制手表
- 高斯消元&线性基模板
- 修改本地网络映射文件
- 高端存储发展趋势
- HBase Filter使用介绍
- OpenGL 版本与GLSL版本
- 查看本机编码方式
- Java基础概念
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this a
- 使用Eclipse的Working Set,界面清爽多了