传送门
先进行高斯消元
因为要求最少的开关次数,那么:
对于关键元,我们可以通过带入消元求出,
对于自由元,我们暴力枚举,进行dfs,因为只有开关两种状态,0或1
#include <cmath> #include <cstdio> #include <iostream> #define N 40 using namespace std; int n, m, sum, mn = ~(1 << 31); int a[N][N], ans[N]; inline void Guass() } inline void dfs(int now, int sum) int i; if(a[now][now]) else } int main() Guass(); dfs(n, 0); printf("%d\n", mn); return 0; }
上一篇:[luoguP3668] [USACO17OPEN]Modern Art 2 现代艺术2(栈)
下一篇:[luoguP2862] [USACO06JAN]把牛Corral the Cows(二分 + 乱搞)
数论 高斯消元 dfs









