随笔分类 -  ACM----字符串

HDOJ 1800 Flying to the Mars
摘要:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1800题目意思:有n个士兵每个人有一个水平值,水平高的的人可以教低的人,意思就是求最少的扫帚,那么我们只要知道找到最大重复元素的次数即可,因为相同的人肯定不能共用一个,所以求得最少即为最大的重复次数注意:前置的0必须要去掉,例如数据 3 0 00 000输出 3代码1(直接map):#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include < 阅读全文

posted @ 2012-06-26 12:57 c语言源码 阅读(200) 评论(0) 推荐(0)

HDOJ 1075 (What Are You Talking About)
摘要:点击打开链接 http://acm.hdu.edu.cn/showproblem.php?pid=1075思路:利用字典树+map ,但是也可以直接利用map来写,用string不要用char注意:这组数据 START dog aa END START a aa END输出:a dog代码(字典树+map):#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <map>using 阅读全文

posted @ 2012-06-25 10:57 c语言源码 阅读(201) 评论(0) 推荐(0)

hdu 1251(字典树) 统计难题 http://acm.hdu.edu.cn/showproblem.php?pid=1251
摘要:解题思路:直接套用字典树的模板,注意以空行结束的判断是 strcmp(str,"")==0代码:#include <iostream>#include <cstdio>#include <cstring>using namespace std;//创建一个字典树结构体struct node{ int num; struct node *br[26];};node *root;//插入字母建立树void Tree_Insert(char str[]){ node *t , *s = root; int i , j; int len = st 阅读全文

posted @ 2012-06-22 18:49 c语言源码 阅读(159) 评论(0) 推荐(0)

导航