2013年4月13日
摘要: 1 #include 2 #include 3 struct Edge 4 { 5 int u,v,w; 6 }edge[10010]; 7 int n,m,sett[110]; 8 int cmp(const struct Edge x,const struct Edge y) 9 {10 return x.w < y.w;11 }12 int ffind(int x)13 {14 if(x != sett[x])15 x = ffind(sett[x]);16 return x;17 }18 int kruskal()19 {20 ... 阅读全文
posted @ 2013-04-13 21:15 straw_berry 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 【DescriptionDescription】We know that if a phone number A is another phone number B’s prefix, B is not able tobe called. For an example, A is 123 while B is 12345, after pressing 123, we call A, and notable to call B.Given N phone numbers, your task is to find whether there exits two numbers A and Bt 阅读全文
posted @ 2013-04-13 19:39 straw_berry 阅读(378) 评论(0) 推荐(0) 编辑
  2013年4月10日
摘要: In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tiling of a 2x17 rectangle.输入Input is a sequence of lines, each line containing an integer number 0 <= n <= 250.输出For each line of input, output one integer number in a separate line giving the number of possib 阅读全文
posted @ 2013-04-10 00:36 straw_berry 阅读(196) 评论(0) 推荐(0) 编辑
  2013年4月2日
摘要: 马拦过河卒Time Limit: 3000MS Memory limit: 65536K题目描述棋盘上A点有一个过河卒,需要走到目标B点。卒行走的规则:可以向下、或者向右。同时在棋盘上C点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点。因此称之为“马拦过河卒”。棋盘用坐标表示,A点(0,0)、B点(n,m)(n,m为不超过15的整数),同样马的位置坐标是需要给出的。现在要求你计算出卒从A点能够到达B点的路径的条数,假设马的位置是固定不动的,并不是卒走一步马走一步。输入一行四个数据,用空格分隔,分别表示B点的坐标和马的坐标。输出一个数据,表示所有的路径条数。示例输入6 6 阅读全文
posted @ 2013-04-02 21:50 straw_berry 阅读(237) 评论(0) 推荐(0) 编辑
  2013年3月30日
摘要: sdut 2141 1 #include 2 #include 3 int mapp[110][110],vis[110],que[110],flag; 4 int k,m,t; 5 void bfs(int t) 6 { 7 int l=0,r=0,tt,j; 8 que[r++]=t; 9 while(l<r) 10 { 11 tt=que[l++]; 12 if(flag==1) 13 { 14 flag=0; ... 阅读全文
posted @ 2013-03-30 21:50 straw_berry 阅读(203) 评论(0) 推荐(0) 编辑
摘要: sdut 2107 图的深度遍历 1 #include 2 #include 3 int map[110][110], vis[110]; 4 int m, n, flag; 5 void dfs (int i) 6 { 7 int j ; 8 vis[i] = 1; 9 if( flag == 1)10 {11 printf("%d",i);12 flag = 0;13 }14 else printf(" %d",i);15 for( j=0; j<n; j++ )16 {... 阅读全文
posted @ 2013-03-30 21:38 straw_berry 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 一. 简单匹配算法先来看一个简单匹配算法的函数:int Index_BF ( char S [ ], char T [ ], int pos ){/* 若串 S 中从第pos(S 的下标0≤pos<StrLength(S))个字符起存在和串 T 相同的子串,则称匹配成功,返回第一个这样的子串在串 S 中的下标,否则返回 -1 */int i = pos, j = 0;while ( S[i+j] != '\0'&& T[j] != '\0')if ( S[i+j] == T[j] )j ++; // 继续比较后一字符else{i ++; j 阅读全文
posted @ 2013-03-30 20:20 straw_berry 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Tom's MeadowTom has a meadow in his garden. He divides it into N * M squares. Initially all the squares were covered with grass. He mowed down the grass on some of the squares and thinks the meadow is beautiful if and only if Not all squares are covered with grass.No two mowed squares are adjace 阅读全文
posted @ 2013-03-30 16:26 straw_berry 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 金牌、银牌、铜牌Time Limit: 1000MS Memory limit: 65536K题目描述Acm——大学中四大竞赛之首——是极具挑战性的大学生竞赛形式。在一场acm比赛中,一个参赛队伍由三人组合而成,在最短的时间内做出尽可能多的题目而且要尽量少提交错误代码,这样才能得到更高的排名。现在让我们模拟一次不正规的acm比赛,假设在比赛开始后30分钟(这时已经有不少同学提交了代码,在rating中已经出现),到比赛结束前,又有新的同学提交(在rating中出现),同时rating在不断变化着,还有一些同学因为一些原因中途退出比赛(这时rating中自动删除,当然在正式比赛中不会有这种情况) 阅读全文
posted @ 2013-03-30 00:24 straw_berry 阅读(415) 评论(1) 推荐(0) 编辑
  2013年3月28日
摘要: virtual judge 树 A题 1 #include 2 #include 3 #include 4 struct node 5 { 6 int flag; 7 struct node *next[26]; 8 }; 9 struct node *creat()10 {11 struct node *p;12 p=(struct node *)malloc(sizeof(struct node));13 for(int i=0;inext[i]=NULL;15 p->flag=1;16 return p;17 }18 void i... 阅读全文
posted @ 2013-03-28 20:23 straw_berry 阅读(203) 评论(0) 推荐(0) 编辑