摘要: 动态规划注意多解的情况View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 100long long value[maxn];char key[maxn], letter[maxn];long long f[maxn][maxn];int from[maxn][maxn];int l, k;int num[maxn];long long sum[maxn];void inp 阅读全文
posted @ 2011-08-31 19:18 undefined2024 阅读(178) 评论(0) 推荐(0)
摘要: 欧拉通路View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int n;char st[1005];bool exist[30];int in[30], out[30];int father[30];int getanc(int a){ if (father[a] == a) return a; return father[a] = getanc(father[a]);}void merge(in 阅读全文
posted @ 2011-08-31 15:37 undefined2024 阅读(231) 评论(0) 推荐(0)
摘要: 题意:一个01矩阵,表示灯的亮灭状态,每次操作可以改变一个十字形状内的五个灯的状态。问能否将所有灯熄灭。分析:高斯消元法对于每个灯的两灭有影响的开关就是它附近十字形内的五个开关。所以对于每个灯可以列一个方程,即周围五个开关异或起来的结果应该可以使该灯熄灭。就是利用线性代数知识,写出增广矩阵,化为阶梯形矩阵,有下到上依次解出各未知量。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>usingnamespace std;#define 阅读全文
posted @ 2011-08-31 15:04 undefined2024 阅读(1356) 评论(0) 推荐(0)
摘要: 二维树状数组View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 1030int c[maxn][maxn];int Row, Col, n;inline int Lowbit(const int &x){ return x & (-x);}int Sum(int i, int j){ int tempj, sum = 0; while (i > 0) 阅读全文
posted @ 2011-08-31 09:07 undefined2024 阅读(261) 评论(0) 推荐(0)