HihoCoder.1196 高斯消元·二 (高斯消元 异或方程组)
来源:互联网 发布:兄弟连php培训怎么样 编辑:程序博客网 时间:2024/06/06 13:00
HihoCoder.1196 高斯消元·二 (高斯消元 异或方程组)
标签(空格分隔): 高斯消元
题意分析
水题一道,不多说了哈。
代码总览
#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#define nmax 35using namespace std;int a[nmax][nmax];int x[nmax];int hashback[nmax][nmax];int Gauss(int equ,int var){ int max_r; int col=0; for(int k = 0;k < equ && col < var;k++,col++){ max_r=k; for(int i=k+1;i<equ;i++){ if(abs(a[i][col])>abs(a[max_r][col])) max_r=i; } if(max_r!=k){ for(int j=k;j<var+1;j++) swap(a[k][j],a[max_r][j]); } if(a[k][col]==0){ k--; continue; } for(int i=k+1;i<equ;i++){ if(a[i][col]!=0){ for(int j=col;j<var+1;j++){ a[i][j]^=a[k][j];; } } } } for(int i = var - 1; i >= 0; i--){ x[i]=a[i][var]; for(int j = i + 1; j < var; j++){ x[i] ^= ( a[i][j] && x[j]); } } return 0;}void init(){ int tot = 0; memset(x,0,sizeof x); memset(a,0,sizeof a); for(int i = 0 ;i<5;++i) for(int j = 0;j<6;++j) hashback[i][j] = tot++; for(int i = 0;i<5;++i){ for(int j = 0;j<6;++j){ int t = hashback[i][j]; a[t][t] = 1; if(i != 0) a[hashback[i-1][j]][t] = 1; if(i != 4) a[hashback[i+1][j]][t] = 1; if(j != 0) a[hashback[i][j-1]][t] = 1; if(j != 5) a[hashback[i][j+1]][t] = 1; } }}int main(){ init(); int temp = 0; for(int i = 0;i<30;++i){ scanf("%1d",&temp); a[i][30] = (!temp); } Gauss(30,30); int ans = 0; for(int i = 0;i<5;++i) for(int j = 0;j<6;++j) if(x[hashback[i][j]] == 1) ans++; printf("%d\n",ans); for(int i = 0;i<5;++i) for(int j = 0;j<6;++j) if(x[hashback[i][j]] == 1) printf("%d %d\n",i+1,j+1); return 0;}
阅读全文
0 0
- HihoCoder.1196 高斯消元·二 (高斯消元 异或方程组)
- [hihocoder #1196 : 高斯消元·二] 高斯消元求异或方程组
- HIHO #1196 : 高斯消元·二(异或方程组)
- [模板]高斯消元,异或方程组
- hihocoder #1196 : 高斯消元·二
- hihocoder-1196 高斯消元·二
- 3364Lanterns (异或方程组高斯消元)
- POJ1830(异或方程组的高斯消元)
- HDU 3364 - Lanterns (高斯消元 + 异或方程组)
- 高斯消元模板(+解异或方程组)
- 【SPOJ-BTTNS】Buttons【高斯消元】【异或方程组】
- HDU 5833 高斯消元 异或方程组
- hiho一下 第五十七周 高斯消元·二(高斯消元解异或方程组)
- UVA 11542 Square 高斯消元 异或方程组求解
- 【POJ1222】EXTENDED LIGHTS OUT 高斯消元、解异或方程组
- 【BZOJ3503】【Cqoi2014】和谐矩阵 高斯消元,解异或方程组
- POJ 1222-EXTENDED LIGHTS OUT(高斯消元求解异或方程组)
- POJ 1222|Extended Lights Out|高斯消元|异或方程组
- 大数阶乘
- HDU 6129 Just do it
- POJ.1681 Painter's Problem(高斯消元 异或方程组)
- 递归-N皇后
- java虚拟机内存大小设置
- HihoCoder.1196 高斯消元·二 (高斯消元 异或方程组)
- android选择图片并使用socket上传图片
- STM32 HAL库实战(一)使用STM32驱动双通道12位DAC(TLV5618)
- 股票分析软件编程开发日记与总结,自动交易软件开发
- CleanMyMac 4 免激活版 免费激活码破解 最新版下载
- Spring静态注入
- kattle使用手册翻译-PDI数据转换教程
- uC/OS-II系统开发笔记
- Eclipse下,选项Add variable attributes to generated class files (used by the debugger)的含义