当前位置:网站首页>Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
2022-07-05 06:18:00 【T Y F666】
Gauss cancel AcWing 884. Solution d'élimination gaussienne pour un système d'équations Xor linéaires
Lien vers la question originale
AcWing 884. Solution d'élimination gaussienne pour un système d'équations Xor linéaires
Étiquette de l'algorithme
Espace linéaire Gauss cancel XOR
Idées

Code
#include<bits/stdc++.h>
#define int long long
#define abs fabs
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 105;
int a[N][N], eps = 1e-8;
int n;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
int gu(){// Gauss cancel, Réponse stockée dans a[i][n]Moyenne,0 <= i < n
// cColonne représentative rLigne représentative
int c, r;
// Liste par colonne
for(c=0, r=0; c<n; ++c){
int t=r;
rep(i, r, n){
if(a[i][c]){// Trouver une ligne non nulle
t=i;
break;
}
}
if(!a[t][c]){
continue;
}
rep(i, c, n+1){// Changez la ligne non nulle en haut
swap(a[r][i], a[t][i]);
}
rep(i, r+1, n){// Utilisez une ligne non nulle avec la colonne suivante pour éliminer à 0
if(a[i][c]){
Rep(j, n, c){
a[i][j]^=a[r][j];
}
}
}
++r;
}
if(r<n){
rep(i, r, n){
if(abs(a[i][n])>eps){
return 2;// Pas de solution
}
}
return 1;// Il y a un nombre infini de solutions de groupe
}
Rep(i, n-1, 0){
rep(j, i+1, n){
a[i][n]^=a[i][j]*a[j][n];
}
}
return 0;// Il y a une solution unique
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
n=read();
rep(i, 0, n){
rep(j, 0, n+1){
a[i][j]=read();
}
}
int t=gu();
if(t==2){
puts("No solution");
}else if(t==1){
puts("Multiple sets of solutions");
}else{
rep(i, 0, n){
printf("%lld\n", a[i][n]);
}
}
return 0;
}
L'originalité n'est pas facile
Réimpression Veuillez indiquer la source
Si ça t'aide N'oublie pas de me soutenir.
边栏推荐
- leetcode-1200:最小绝对差
- [rust notes] 15 string and text (Part 1)
- Spark中groupByKey() 和 reduceByKey() 和combineByKey()
- Chart. JS - Format Y axis - chart js - Formatting Y axis
- MIT-6874-Deep Learning in the Life Sciences Week 7
- One question per day 1020 Number of enclaves
- leetcode-22:括号生成
- 传统数据库逐渐“难适应”,云原生数据库脱颖而出
- Currently clicked button and current mouse coordinates in QT judgment interface
- MySQL advanced part 2: storage engine
猜你喜欢

Liunx starts redis

LeetCode 0107.二叉树的层序遍历II - 另一种方法

MySQL advanced part 2: storage engine

Traditional databases are gradually "difficult to adapt", and cloud native databases stand out

Leetcode-6108: decrypt messages

Open source storage is so popular, why do we insist on self-development?

Quickly use Amazon memorydb and build your own redis memory database

SQLMAP使用教程(一)

Appium foundation - use the first demo of appium

MySQL advanced part 1: View
随机推荐
leetcode-31:下一个排列
[rust notes] 15 string and text (Part 1)
【Rust 笔记】16-输入与输出(下)
[rust notes] 13 iterator (Part 2)
LeetCode 0107. Sequence traversal of binary tree II - another method
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
Data visualization chart summary (I)
Sqlmap tutorial (II) practical skills I
Niu Mei's math problems
[leetcode] day94 reshape matrix
【Rust 笔记】13-迭代器(中)
[BMZCTF-pwn] ectf-2014 seddit
阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队
927. Trisection simulation
leetcode-6110:网格图中递增路径的数目
做 SQL 性能优化真是让人干瞪眼
1041 Be Unique
QQ computer version cancels escape character input expression
剑指 Offer II 058:日程表
Golang uses context gracefully