上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 42 下一页
摘要: 题意:s到t的第K短路View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<stdlib.h> 5 #include<algorithm> 6 #include<queue> 7 using namespace std; 8 const int maxn = 1005; 9 const int maxm = 200005; 10 const int inf = 9999999; 11 struct node{ 12 阅读全文
posted @ 2013-02-23 21:07 xxx0624 阅读(737) 评论(0) 推荐(0) 编辑
摘要: SPFA题意:给定一张图,从1到n。求1到n的最短路,但是可能存在某条路被阻断了,即为inf了。这条路必定是存在最短路中。所以枚举最短路中的路径。。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<queue> 5 #include<algorithm> 6 using namespace std; 7 const int maxn = 1005; 8 const int maxm = 1005*500; 9 con 阅读全文
posted @ 2013-02-21 23:26 xxx0624 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 题意:s到e,最短时间且至少经过k条边dis[ i ][ j ]:表示s到i至少经过了j条边的最少时间!二维spfaView Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<queue> 4 #include<algorithm> 5 #include<stdlib.h> 6 using namespace std; 7 const int maxn = 5005; 8 const int maxm = 100005; 9 const int inf = 9999999 阅读全文
posted @ 2013-02-21 22:03 xxx0624 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 最短路floydView Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn =11; 4 int sea[ maxn ]; 5 int mat[ maxn ][ maxn ]; 6 const int inf=999999; 7 8 void init(){ 9 memset( sea,0,sizeof(sea));10 for( int i=0;i<maxn;i++ )11 for( int j=0;j<maxn;j++ )12 mat[ i ][ j ]=... 阅读全文
posted @ 2013-02-21 16:11 xxx0624 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一些单词,前一个的尾和后一个的头相同时,才表示他们相连求最短路View Code 1 #include<stdio.h> 2 #include<string> 3 #include<stdlib.h> 4 #include<queue> 5 #include<map> 6 #include<algorithm> 7 using namespace std; 8 const int maxn = 1015; 9 const int inf = INT_MAX; 10 //map<string,int>m 阅读全文
posted @ 2013-02-21 16:09 xxx0624 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 题意:从一点到另外一点的最短距离因为点的个数较小 用floydView Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int maxn = 81; 8 struct node{ 9 int mat[ maxn ][ maxn ]; 10 }a[ maxn ]; 11 struct node2{ 12 int 阅读全文
posted @ 2013-02-21 11:46 xxx0624 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 题意:找一条从第一行到最后一行的最短路dfs用于重新建图。bfs即可View Code 1 #include<stdio.h> 2 #include<queue> 3 #include<string.h> 4 #include<stdlib.h> 5 #include<map> 6 #include<algorithm> 7 using namespace std; 8 const int maxn = 22; 9 const int inf=9999999; 10 char mat[ maxn ][ maxn ]; 11 阅读全文
posted @ 2013-02-20 23:57 xxx0624 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 题意:小数化分数有限小数:小数点后面有几位就乘以 10^n 最后 分子则为乘积,分母则为1*10^n (记得约分)混无限循环小数:循环节+非循环节(’+‘表示连接起来)-非循环节=分子分母:循环节有几位(从左往右)就有几位9,非循环节有几位就有几位0比如:0.1(305)分子:1305-1分母:9990纯循环小数:设n=循环节的位数分子=10^n*(小数部分也就是循环节)分母=n位9例如:0.(3053)分子=3053分母=9999附代码View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<stri 阅读全文
posted @ 2013-02-20 21:43 xxx0624 阅读(393) 评论(0) 推荐(0) 编辑
摘要: 简单View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 const int maxn = 105; 6 int mat[ maxn ][ maxn ]; 7 int x[4],y[4]; 8 int main(){ 9 int x1,y1,x2,y2;10 memset( mat,0,sizeof( mat ) );11 while( scanf("%d%d%d%d",&x1,&y 阅读全文
posted @ 2013-02-18 21:16 xxx0624 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 打素数表View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 10010; 4 int shu[ maxn ],prime[ maxn ]; 5 void get_prime( ){ 6 for( int i=1;i<maxn;i+=2 ) shu[ i ]=1; 7 for( int i=0;i<maxn;i+=2 ) shu[ i ]=0;//0 is stand for not prime 8 shu[ 1 ]=0; 9 shu[ 2 ]=1;10 for( i... 阅读全文
posted @ 2013-02-18 10:04 xxx0624 阅读(408) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 42 下一页