上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 71 下一页
摘要: http://poj.org/problem?id=3687样例太唬人了,求得是从1到N重量 而不是排好序的标签逆向建图 把最重的赋给第一个入度为0的标签 如有多个赋给标签大的 这样能保证重量大的在后面View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int to[301],w[301][301],de[301],tt[301]; 7 int topo(int n 阅读全文
posted @ 2012-12-06 16:05 _雨 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 枚举所有的 排序View Code 1 /* 2 ID: your_id_here 3 PROG: frac1 4 LANG: C++ 5 */ 6 #include <iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<algorithm>10 using namespace std;11 int w[201][201];12 struct node13 {14 int x,y;15 double s;16 }q[20001];17 void gcd(int x,int y)1 阅读全文
posted @ 2012-12-03 21:32 _雨 阅读(138) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2493题意:对于一个给定的无向图,求其中有一条边的边权可以减半的情况下 从 A 点到 B 点的最短路。 做法:可以用spfa求出 A 到所有点的最短路 dis 和 B 到所有点的最短路 dis1 。然后枚举所有边(u,v),找出最小的dis[ u ] + w(u,v) / 2 + dis1[ v ] 即可,如果A、B不可达,输出“No solution”。 View Code 1 #include <iostream> 2 #inc 阅读全文
posted @ 2012-12-03 10:13 _雨 阅读(250) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2497并查集 给定一个无向图 判断s点是否在所有的环中感觉解释有点绕 边输入边判断 s不加入判断 也就是s的祖先一直是s 如果两个节点的祖先一样那说明形成了环若s在环中 那说明节点的祖先肯定是s 否则s不在其中s不参与连接 如果一个环中一个节点不跟相邻节点连接 就形不成环 除非这个节点不在这个环中View Code 1 #include <iostream> 2 #include<cstdio> 3 #include&l 阅读全文
posted @ 2012-12-02 18:57 _雨 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 12 13打表而过View Code 1 #include <iostream> 2 /* 3 ID: your_id_here 4 PROG: checker 5 LANG: C++ 6 */ 7 #include<cstdio> 8 #include<cstring> 9 #include<cmath>10 using namespace std;11 int f[20][20],num[20],n,t;12 void dfs(int v,int x)13 {14 int j,g,i,ff = 0;15 if(v<=n)16 num[v 阅读全文
posted @ 2012-11-18 20:55 _雨 阅读(186) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2465View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 typedef struct node 7 { 8 int x1,y1,x,y,num,flag1; 9 friend bool operator<( stru 阅读全文
posted @ 2012-11-18 19:12 _雨 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 预处理出前4位的超级素数,再枚举后四位View Code 1 /* 2 ID: your_id_here 3 PROG: sprime 4 LANG: C++ 5 */ 6 #include <iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<cmath>10 #include<algorithm>11 using namespace std;12 int num[10][1000],f[20],g,n,k[10],nn[10000],kk;13 int prime 阅读全文
posted @ 2012-11-16 21:24 _雨 阅读(165) 评论(0) 推荐(0) 编辑
摘要: dfs搜前5位数 根据前面的算后面的View Code 1 /* 2 ID: your_id_here 3 PROG: pprime 4 LANG: C++ 5 */ 6 #include <iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<cmath> 10 #include<algorithm> 11 using namespace std; 12 int a,b,g; 13 int kk[10000],f[20][20],tt,ff[100000]; 14 c 阅读全文
posted @ 2012-11-15 21:23 _雨 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 最基础的数字三角形View Code 1 #include <iostream> 2 #include<cstdio> 3 /* 4 ID: your_id_here 5 PROG: numtri 6 LANG: C++ 7 */ 8 #include<cstring> 9 #include<algorithm>10 using namespace std;11 int a[1010][1010];12 long long dp[1010][1010];13 int main()14 {15 freopen("numtri.in&quo 阅读全文
posted @ 2012-11-14 21:15 _雨 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 刚开始理解错题意了,写了半天的dfs,直接delete。写的挺多,不是太复杂,对于每种状态枚举6种情况。View Code 1 /* 2 ID: your_id_here 3 PROG: milk3 4 LANG: C++ 5 */ 6 #include <iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<algorithm> 10 using namespace std; 11 int a,b,c,num[50],f[30][30][30],ff[50],g; 12 void 阅读全文
posted @ 2012-11-14 20:22 _雨 阅读(333) 评论(0) 推荐(0) 编辑
上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 71 下一页