上一页 1 2 3 4 5 6 7 8 9 ··· 18 下一页
View Code #include<stdio.h>#include<string.h>#define maxn 110#define maxm maxn * maxn#define inf 1000000000int min(int a, int b){ return a < b ? a : b;}struct E{ int v, next;}edge[maxm<<1];int head[maxn], tot;int n, m;void add(int s, int t){ edge[tot].v = t; edge[tot].next = hea Read More
posted @ 2012-11-01 20:49 To be an ACMan Views(154) Comments(0) Diggs(0)
http://www.cppblog.com/LeoW/archive/2012/03/08/167427.htmlView Code #include<stdio.h>#include<string.h>#include<math.h>#define lld __int64int main(){ int i, j, cas; int n; scanf("%d", &cas); while(cas--) { scanf("%d", &n); double sum1 = n*log10(n*1.0); l Read More
posted @ 2012-10-29 22:03 To be an ACMan Views(107) Comments(0) Diggs(0)
http://www.cnblogs.com/183zyz/archive/2011/04/12/2013372.htmlView Code #include<stdio.h>#include<string.h>int f(int x){ int i, sum = 1; for(i = 1; i <= x; i++) sum *= 10; return sum;}int gcd(int a, int b){ return b ? gcd(b, a%b) : a;}int main(){ int i, j, cas; char s[33]; ... Read More
posted @ 2012-10-29 22:02 To be an ACMan Views(196) Comments(0) Diggs(0)
思路:枚举每张牌,然后加入这张牌,看这牌是否能胡。判胡:1.注意特判 7 对子,九一 这两个胡牌规则 2.(胡的牌里必须有一个对子)枚举这个对子,然后再进行处理就方便多了注意:情况1特判和情况2的牌可能会重复,要去重。View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int vis[6][11], num[6][11];char a[15][5];struct node{ int x, y; node(){} node(int xx, int Read More
posted @ 2012-10-27 22:03 To be an ACMan Views(491) Comments(0) Diggs(0)
用拆点把点权变为边权。然后用最大流求解每对u、v(u != v),取其中的最小值注意:具体操作时,有个技巧,可以将枚举从O(n^2)优化到O(n):先固定一个点,然后枚举另一个点即可。很显然的一个结论:max_flow(1->2->3) < max_flow(2->3)我们要取其中的最小,可以不必去求2->3的最大流如果以1为源点,汇点只能是剩下的几个点,枚举汇点即可。本题要多次求最大流,所以每求一次要重新还原原图代码1:先把原图的信息保存在map数组里,每次都重新建图。View Code #include<stdio.h>#include<st Read More
posted @ 2012-10-27 00:26 To be an ACMan Views(275) Comments(0) Diggs(0)
提两点:1.对于每个点连通分量,都是根据割点来找的。2.边入栈, 到当前边等于栈顶时停止出栈。3.割点属于多个点连通分量。邻接矩阵:View Code #include<stdio.h>#include<string.h>#define maxn 22#define maxm 444#define inf 1000000000int min(int a, int b){ return a < b ? a : b;} int n, m;bool map[maxn][maxn];struct EE{ int u, v; void print() { print... Read More
posted @ 2012-10-26 21:39 To be an ACMan Views(381) Comments(0) Diggs(0)
注意:对于生成树的每条边<u,v>:u是割点的充要条件是:1、若u为根节点, 它有2个以上包括两个的儿子(son >= 2)2、u不为根节点,dfn[u] <= low[v];View Code #include<stdio.h>#include<string.h>#define maxn 1005#define maxm maxn*maxnint min(int a, int b) { return a < b ? a : b;}int max(int a, int b) { return a > b ? a : b;}struct Read More
posted @ 2012-10-26 18:54 To be an ACMan Views(258) Comments(0) Diggs(0)
题意:给出n栋房子位置和每栋房子里面的人数,m个避难所位置和每个避难所可容纳人数。然后给出一个方案,判断该方案是否最优,如果不是求出一个更优的方案。思路:很容易想到用最小费用流求出最优时间,在与原方案花费时间对比判断原方案是否最优。但是这种方法会超时的。 放弃该思路。看看题目没要求要最优解,而是得到一个更优的解,那么如果在原图中能够找到一个总费用为负的回路的话,那就该解不是最优解,把该负环消去,更新流量,得到优化后的解。具体操作:在SPFA中,一个点入队次数大于顶点数时就可以判断有负圈存在了,但这时刚刚入队的这个点却未必是负圈上的,如数据1 30 0 41 0 61 1 61 2 60 2 2 Read More
posted @ 2012-10-25 20:22 To be an ACMan Views(537) Comments(0) Diggs(0)
View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<queue>using namespace std;#define maxn 110#define maxm 6000#define inf 1000000000int min(int a, int b){ return a < b ? a : b;}struct E{ int u, v, next, c, w;}edge[maxm<<2];int head[maxn], tot;in Read More
posted @ 2012-10-24 16:50 To be an ACMan Views(148) Comments(0) Diggs(0)
View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<queue>using namespace std;#define maxn 100300#define maxm 200003#define inf 1000000000int min(int a, int b){ return a < b ? a : b;}struct E{ int u, v, c, w, next;}edge[maxm<<3];int head[maxn], t Read More
posted @ 2012-10-24 16:45 To be an ACMan Views(169) Comments(0) Diggs(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 18 下一页