![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
基础ACM
gneveek
T_T此号终于找回,以后要注意安全。
展开
-
hdu1097
http://acm.hdu.edu.cn/showproblem.php?pid=1097 思路:只算a的最后一位的b次方就可以了,算的中间结果也只取最后一位继续…… 然后就会出现循环 比如8的800次方,8^1 % 10 = 8; 8^2 % 10 = 4; 8^3 % 10 = (8^2%10) *8%10 = 6; ..................原创 2012-05-28 17:43:05 · 2574 阅读 · 0 评论 -
HDU1671 Phone List(必须删除字典树,否则Memory Limit Exceeded)
简单的字典树题 目,但是这题有多组测试实例,所以每次建立完的字典树都要删除掉,开始时没删,结果内存超了8MB左右 加了delete操作后内存占用从39MB降到了3320K 删除用的是递归,是参考Discuss里的方法,之前自己用非递归写的,很麻烦,效果也不好,在此谢过分享代码的同学 下面是AC的代码: // hdu1671 #include #include原创 2012-07-27 17:45:58 · 1411 阅读 · 0 评论 -
HDU 1075
/* ***************************************************** * 题目:HDU 1075 * 地址:http://acm.hdu.edu.cn/statistic.php?pid=1075 * 状态:AC ***************************************************** *原创 2012-07-25 15:54:33 · 1571 阅读 · 0 评论 -
hdu_OJ_2222
// 题目:hdu_2222 // 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2222 // 状态:Accept /** * 这题是用字典树做的,效率不太高,其中还有很多地方有待优化 * * 缺陷:每个实例都重新建一颗字典树,没有释放资源,如果测试实例太多,将占用大量内存。 */ #include #include struct n原创 2012-07-23 15:09:24 · 1702 阅读 · 0 评论 -
基数排序_FAFU_1270
基数排序的介绍: http://baike.baidu.com/view/1170573.htm 基数排序的方式可以采用LSD(Least significant digital)或MSD(Most significant digital),LSD的排序方式由键值的最右边开始,而MSD则相反,由键值的最左边开始。 以LSD为例,假设原来有一串数值如下所示:原创 2012-07-19 01:24:01 · 12821 阅读 · 0 评论 -
HDU_1804_Deli Deli (字典树)
http://acm.hdu.edu.cn/showproblem.php?pid=1804 #include #include const int words_max_length = 23; //单词的最大长度,题目给的是20 struct node{ node * child[26]; char word[words_max_length]; node(){memse原创 2012-07-17 15:15:31 · 862 阅读 · 0 评论 -
FZU 1961 凯撒密码II HDU 1251(字典树)
FZU 1961 凯撒密码II http://acm.fzu.edu.cn/problem.php?pid=1961 #include struct node{ node * child[27]; int value; }* root = new node(); //node * root = new.. void add_string(char * str, int原创 2012-07-16 11:01:33 · 1487 阅读 · 0 评论 -
Fafu 1266 数数(hash应用)
http://acm.fafu.edu.cn/problem.php?id=1266 把2^31范围内的数 %10000求得真hash值 把值存到hash链表中 #include #include struct node{ int val; node * next; }hash[10000]; int main() { freopen("E:\\input.t原创 2012-07-14 10:30:59 · 897 阅读 · 0 评论 -
FAFU1073 队长的情书
这题简直就是坑爹! 因为图没显示全!(把图另存到本地看!后面还有两个字母,R和S) 而且是下面的是密文,上面是对应的翻译! 我靠,玩人呢? // Date: 2012-07- // URL: #include #include using namespace std; char a[]= { 'B','C','D','A','I','J','G','K',原创 2012-07-12 09:26:29 · 883 阅读 · 0 评论 -
FAFU1064 Total求和
#include using namespace std; #define TEMP_LEN 110 char ans[256]; char str[512]; char temp[TEMP_LEN]; void reverse_string(char * str) { //把字符串str倒置 int len = strlen(str); for(int i = 0; i<l原创 2012-07-12 21:53:41 · 783 阅读 · 0 评论 -
HDU-2037今年暑假不AC(贪心算法)
http://acm.hdu.edu.cn/showproblem.php?pid=2037 以节目结束时间作为贪心搜索的依据。 证明贪心算法在此问题中适用: (反证法) 如图所示…… AC代码: #include using namespace std; int int_comp(const void *a, const void原创 2012-07-11 10:26:54 · 1282 阅读 · 0 评论 -
HDU1877 又一版 A+B
注意最大和最小值就OK了。 SampleInput: 8 1300 48 2 1 7 2 2147483647 2147483647 2 0 0 0 SampleOutput: 2504 1000 11111111111111111111111111111110 0 #include #define MAXN 35 using namespace std; int原创 2012-05-25 20:45:07 · 1194 阅读 · 0 评论 -
黑白图像 -- 刘汝佳白书P107
输入一个n*n的黑白图像(1表示黑色,0表示白色),任务是统计其中八连块的个数。如果两个黑格子有公共边或者公共顶点,就说它们属于同一个八连块。 (题意是让求连在一起的块有几个,图见书本) SamInput 6 100100 001010 000000 110000 111000 010100 #include #define MAXN 30 using namespace原创 2012-05-22 22:28:31 · 8165 阅读 · 0 评论 -
1020寒星孤月-蛇形矩阵
地址:http://gstz.3322.org:7860/JudgeOnline/showcontest?contest_id=1001 Description asd在研究完斐波那契数列之后,又迷上了矩阵,特别是蛇形矩阵,为了再次让大家纠结一下,特别定义了一种蛇形矩阵,命名为寒星孤月蛇形矩阵。 寒星孤月蛇形矩阵是由1 开始的自然数依次排列成的一个矩阵上三角形。如下图所示: I原创 2012-05-21 21:55:53 · 2790 阅读 · 0 评论 -
istringstream用法,HDU1106排序
http://acm.hdu.edu.cn/showproblem.php?pid=1106 #include #include #include using namespace std; string s; int data[600]; int intCmp(const void *a, const void *b) { return *(int *)a - *(in原创 2012-05-29 14:26:03 · 863 阅读 · 0 评论 -
HDU 2896 病毒侵袭
这题 可用字典树做,也可用AC自动机做,需要注意的是,ASCII可见字符包括从33~126的字符,0~32 和127均为不可见字符(控制字符和换行,空格之类的) 所以在构造字典树的时候,可以让节点的子孩子数定义为 127 - 33 = 94 struct node{ int number; //病毒编号 node * child[94]; //ASCII可见字符原创 2012-07-28 15:11:13 · 1877 阅读 · 0 评论