随笔分类 -  ACM_HDU

HDU-1394-Minimum Inversion Number
摘要:HDU-1394-Minimum Inversion Numberhttp://acm.hdu.edu.cn/showproblem.php?pid=1394题意是给出n个数,求其逆序数,并每次将第一个数移至最后,再求其逆序数,求这n个排列中逆序数最小的一个逆序数的简单定义:The inversion number of a givennumber sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i< j and ai > aj.假设已求得一个排列的逆序数为sum,并且数组为a[n],现把第 阅读全文

posted @ 2012-07-21 10:05 java课程设计例子 阅读(161) 评论(0) 推荐(0) 编辑

HDU-1698-Just a Hook
摘要:HDU-1698-Just a Hookhttp://acm.hdu.edu.cn/showproblem.php?pid=1698还是成段更新线段树#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100005 struct cam { int x; int y; int sum; int val; }list[N*4]; void build(int k,int x,int y) { int mid; list[k].x=x; list[k].y=y; list[k].va 阅读全文

posted @ 2012-07-20 17:32 java课程设计例子 阅读(172) 评论(0) 推荐(0) 编辑

HDU-1166-敌兵布阵
摘要:HDU-1166-敌兵布阵http://acm.hdu.edu.cn/showproblem.php?pid=1166求区间的和,并可更新,线段树#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 50005 int num[N]; struct cam { int x; //起点 int y; //终点 int sum; //总数 }list[N*4]; void build(int k,int x,int y) { int mid; list[k].x=x; list[k]. 阅读全文

posted @ 2012-07-19 08:10 java课程设计例子 阅读(194) 评论(0) 推荐(0) 编辑

HDU-3074-Multiply game
摘要:HDU-3074-Multiply gamehttp://acm.hdu.edu.cn/showproblem.php?pid=3074求区间元素的乘积,可以更新元素,线段树即可#include<stdio.h> #include<string.h> #include<stdlib.h> #define Mod 1000000007 #define N 50005 int num[N]; struct cam { int x; //起点 int y; //终点 __int64 mul; //乘积 }list[N*4]; void build(int k,in 阅读全文

posted @ 2012-07-18 23:34 java课程设计例子 阅读(123) 评论(0) 推荐(0) 编辑

HDU-1754-I Hate It
摘要:HDU-1754-I Hate Ithttp://acm.hdu.edu.cn/showproblem.php?pid=1754查询区间的最大值,并可以更新线段树即可,如图为区间[1,5]的线段树#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 200005 int num[N]; struct cam { int x; //起点 int y; //终点 int max; //区间的最大值 }list[N*4]; int Max(int x,int y) { return x& 阅读全文

posted @ 2012-07-18 21:52 java课程设计例子 阅读(132) 评论(0) 推荐(0) 编辑

HDU-2846-Repository
摘要:HDU-2846-Repositoryhttp://acm.hdu.edu.cn/showproblem.php?pid=2846题意是给出一些模式串,再给出几个询问,询问给出的字符串在多少个模式串中出现比如字符串abc所含的字串有a,ab,abc,b,bc,c可用字典树解决,字典树能很好的处理前缀出现的次数,所以可将模式串分解,依次插入需要注意的是对于同一个模式串的不同子串可能有相同的前缀,为了避免多次计算,可以添加字典树节点的信息,添加num记录最后插入的字符串是第num个模式串的子串#include<iostream> #include<cstdio> #incl 阅读全文

posted @ 2012-07-17 09:48 java课程设计例子 阅读(180) 评论(0) 推荐(0) 编辑

HDU-1247-Hats Words
摘要:HDU-1247-Hats Wordshttp://acm.hdu.edu.cn/showproblem.php?pid=1247还是字典树的题目,将每个单词分成两个单词即可,查找是否两个单词均在字典树中注意建树的时和之前略有区别,这题在插入单词时,只需记录单词结尾的节点,不需要记录一个单词的所有前缀#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; char word[50005][20]; struct nod 阅读全文

posted @ 2012-07-16 23:45 java课程设计例子 阅读(161) 评论(0) 推荐(0) 编辑

HDU-1251-统计难题
摘要:HDU-1251-统计难题http://acm.hdu.edu.cn/showproblem.php?pid=1251基本的字典树,字典树又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来节约存储空间,最大限度地减少无谓的字符串比较,查询效率比哈希表高。如上图所示,每一个红色节点都一个单词,白色节点表示公共前缀#include<iostream> #include<cstdio> #include<cstring& 阅读全文

posted @ 2012-07-16 16:55 java课程设计例子 阅读(220) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示