摘要: 题意:从起点到终点bfs即可注意P的作用:一遇到P即将所有的P进队。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 = 5005; 8 const int inf=999999; 9 char mat[ maxn ][ maxn ];10 bool vis[ maxn ][ maxn 阅读全文
posted @ 2013-01-29 14:16 xxx0624 阅读(311) 评论(0) 推荐(1) 编辑
摘要: 题意:整数划分问题是将一个正整数n拆成一组数连加并等于n的形式,且这组数中的最大加数不大于n。View Code 1 #include<stdio.h> 2 const int maxn = 124; 3 int dp[ maxn ][ maxn ]; 4 int main(){ 5 for( int i=0;i<maxn;i++ ){ 6 //dp[ 0 ][ i ]=dp[ i ][ 0 ]=0; 7 dp[ 1 ][ i ]=dp[ i ][ 1 ]=1; 8 } 9 for( int i=2;i<=120;i++ ){10 ... 阅读全文
posted @ 2013-01-29 10:13 xxx0624 阅读(484) 评论(0) 推荐(0) 编辑
摘要: 题意:求N个数全排列,顺着数第M个调用函数即可快速搞定。View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 const int maxn = 1002; 7 int num[ maxn ]; 8 int main(){ 9 int n,m;10 while( scanf("%d%d",&n,&m)!=EOF ){11 mem 阅读全文
posted @ 2013-01-29 09:31 xxx0624 阅读(838) 评论(0) 推荐(0) 编辑
摘要: 题意:从起点到终点,输出路径长度,时间。bfs+记录路径View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<queue> 5 const int N = 105; 6 const int inf = 9999999; 7 using namespace std; 8 9 struct node{ 10 int x,y; 11 }; 12 node p,pp,path[N][N]; 13 struct node2{ 14 int x1, 阅读全文
posted @ 2013-01-29 09:28 xxx0624 阅读(541) 评论(0) 推荐(0) 编辑
摘要: 题意简单View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<algorithm> 5 using namespace std; 6 const int maxn = 1005; 7 char s[ maxn ]; 8 char ch[ maxn ]; 9 int mm[ maxn ];10 int main(){11 while( scanf("%s",ch)!=EOF ){12 int len;13 len=strl 阅读全文
posted @ 2013-01-29 09:24 xxx0624 阅读(237) 评论(0) 推荐(0) 编辑