上一页 1 ··· 72 73 74 75 76 77 78 79 80 ··· 182 下一页
摘要: 差分约束系统差分约束系统有两种方式可以求解,最短路和最长路。当我们把不等式整理成d[a]+w<=d[b]时,我们求最长路。整理成d[a]+w>=d[b]时,我们求最短路。当求最短路时,我们通常要把各点距离初始化为正无穷,求最短路,把各点距离逐渐减小,直到符合所有不等式。也就是开始各点不符合条件,后来通过减小变得符合了,所以一定是符合条件的最大值。既然是求最大值,并且是减小各点距离,也就是把各点由数轴的右侧向左侧拉,所以我们一定要选择一个最终在数轴最左侧的点,并初始化为0,把所有正无穷的点拉近到符合不等式。最长路同理。另外本题我的做法判断impossible的情况是不完全的,暂未发现 阅读全文
posted @ 2011-09-16 16:20 undefined2024 阅读(899) 评论(0) 推荐(0)
摘要: 字符串处理View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;string st;int main(){ //freopen("t.txt", "r", stdin); cin >> st; bool java = false; bool cpp = false; if (st[0] == '_') { cout << 阅读全文
posted @ 2011-09-15 21:13 undefined2024 阅读(343) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 105int n, m;int f[maxn];int g[maxn];bool vis[maxn];void input(){ scanf("%d%d", &n, &m); for (int i = 0; i < n; 阅读全文
posted @ 2011-09-15 20:52 undefined2024 阅读(203) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 1005int n;int f[maxn][maxn];int gcd(int x, int y){ if (!x || !y) return x > y ? x : y; for (int t; t = x % y; x = y, y = t) ; return y;}int main(){ //freop 阅读全文
posted @ 2011-09-15 18:38 undefined2024 阅读(187) 评论(0) 推荐(0)
摘要: 简单模拟,每次看当前的牌是否与初始状态相同,若相同则说明进入循环。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 205char s1[maxl], s2[maxl], aim[maxl], st[maxl], s3[maxl];int l;int main(){ //freopen("t.txt", "r", stdin); 阅读全文
posted @ 2011-09-15 18:05 undefined2024 阅读(245) 评论(0) 推荐(0)
上一页 1 ··· 72 73 74 75 76 77 78 79 80 ··· 182 下一页