当前位置:网站首页>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 recursion
- 4. Object mapping Mapster
- NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
- Record the process of configuring nccl and horovod in these two days (original)
- 数据可视化图表总结(一)
- 【Rust 笔记】13-迭代器(中)
- leetcode-3:无重复字符的最长子串
- leetcode-556:下一个更大元素 III
- 对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
- 剑指 Offer II 058:日程表
猜你喜欢

QQ电脑版取消转义符输入表情

liunx启动redis

MySQL advanced part 1: View

LaMDA 不可能觉醒吗?

MySQL advanced part 2: optimizing SQL steps
![[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian](/img/f1/e7a8a1a31bc5712d9f32d91305a2b0.jpg)
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian

SPI 详解

Appium自动化测试基础 — Appium测试环境搭建总结

RGB LED infinite mirror controlled by Arduino

Quickly use Amazon memorydb and build your own redis memory database
随机推荐
SPI 详解
NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
Niu Mei's math problems
可变电阻器概述——结构、工作和不同应用
4. Object mapping Mapster
博弈论 AcWing 894. 拆分-Nim游戏
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
Leetcode-9: palindromes
传统数据库逐渐“难适应”,云原生数据库脱颖而出
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
MySQL advanced part 2: storage engine
LaMDA 不可能觉醒吗?
栈 AcWing 3302. 表达式求值
1039 Course List for Student
SQL三种连接:内连接、外连接、交叉连接
Record the process of configuring nccl and horovod in these two days (original)
[rust notes] 16 input and output (Part 2)
Nested method, calculation attribute is not applicable, use methods
Leetcode-556: the next larger element III
LeetCode-61