上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 42 下一页
摘要: 题意:给定n,m,c 和 k个数求最小的一个数(这个数是c进制,且是n的倍数)一共5000个状态,bfs不会写DFS啊。。。。不过看了别人的BFS后还是有种恍然大悟的感觉。。。。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string> 4 #include<algorithm> 5 #include<math.h> 6 #include<iostream> 7 #include<queue> 8 using namespace s 阅读全文
posted @ 2013-02-27 21:36 xxx0624 阅读(476) 评论(0) 推荐(0) 编辑
摘要: 水题~~字符串的处理+排序View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 const int maxn = 5005; 6 struct node{ 7 char name[ 105 ]; 8 int win,lost,diff,score; 9 }team[ maxn ];10 int cnt;11 void init( int n ){12 for( int i=0;i<=n;i++ ){13 team 阅读全文
posted @ 2013-02-27 19:35 xxx0624 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一张图,求从1到n+1的最长距离。bfs即可,没什么技巧。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<algorithm> 5 #include<queue> 6 #include<stack> 7 using namespace std; 8 const int maxn = 105; 9 const int maxm = 10000; 10 const int inf = 99999999 阅读全文
posted @ 2013-02-26 23:20 xxx0624 阅读(484) 评论(3) 推荐(0) 编辑
摘要: 1219 水~View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 30; 4 int a[ maxn ]; 5 char s[ 100005 ]; 6 int main(){ 7 while( gets( s )!=NULL ){ 8 memset( a,0,sizeof( a ) ); 9 int len=strlen( s );10 for( int i=0;i<len;i++ ){11 if( s[i]>='a'&&s[... 阅读全文
posted @ 2013-02-26 18:48 xxx0624 阅读(557) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一张图,从1到n,若能随便去除一条路,问最短路?注意:两点可能存在多条路,这时 事实上只要保存下第一短和第二短的,然后在枚举的时候每次去除一条换上第二短的路。。。。。这样最后就能得到ans。(若存在某种方法使得1不能到n,则break,print -1 )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 阅读全文
posted @ 2013-02-26 14:42 xxx0624 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一张图,每个点都有一个power值,到每个点都要一定的距离 消耗一定的油量,求从0出发到某些点 使得 油量消耗最少且power值达到一半。可以floyd或者spfa求出0到各点的距离 dis[ maxm ]。然后就可以转化为:从dis[]中挑出某些点,使得距离和最小且power值达到某个值。从01背包中可以发现:从给定的一些物品中挑出一些放入一个背包中,使得不超过背包体积。这是我们可以把dis当做每个物品的体积,power当做价值。然后从dp中搜到一个power值满足条件的最小的 i 即可View Code 1 #include<stdio.h> 2 #include&l 阅读全文
posted @ 2013-02-25 23:36 xxx0624 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 题意 给定一张图,计算从1到各点的最短距离+各点到1的最短距离。spfa即可,分别正向,反向建一个图。水~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 = 1000005; 8 const int maxm = 1000015; 9 const int inf = 99999999 阅读全文
posted @ 2013-02-24 22:31 xxx0624 阅读(594) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一些人,这些人要到同一个地点去,求最先到达的人。spfa(反向加边就行) 水~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 = 315; 8 const int maxm = 5015; 9 const int inf = 9999999; 10 int cnt,head 阅读全文
posted @ 2013-02-24 21:44 xxx0624 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 水题~~~不要去关心题意中为什么10进制38在火星上表示成1110,其实我也不知道,但是这并不影响做题。例如:4,2,0 1,2,0个位0+0=0<2 所以就是02+2>3 所以为1 且进位14+1+1(进位)=6>5 所以就是1结果 1 1 1 0View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 阅读全文
posted @ 2013-02-23 22:51 xxx0624 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 水题~~~注意:若k比a,b大,默认没有的位数上为0!View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 int a,b,k; 7 while( scanf("%d%d%d",&a,&b,&k)!=EOF ){ 8 if( a==0&&b==0 ) 9 break;10 char aa[ 24 ],bb[ 24 ];11 mems 阅读全文
posted @ 2013-02-23 21:42 xxx0624 阅读(237) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 42 下一页