摘要: 题目http://acm.hdu.edu.cn/showproblem.php?pid=1061;郁闷了半天,原先的wa代码为(第一次没头没脑地做,全乱了):#includeusing namespace std;int main(void){int n,a,rnum,b[10000],order;cin>>n;while(n--){ cin>>a; rnum=a; if(rnum... 阅读全文
posted @ 2011-04-23 21:29 cchun 阅读(186) 评论(0) 推荐(0) 编辑
摘要: HDU1016题目http://acm.hdu.edu.cn/showproblem.php?pid=1016;#include#includeusing namespace std;int n;int number[100],visited[100];bool isprime(int a){ int flag=0; for(int i=2;i>n) { cout#... 阅读全文
posted @ 2011-04-23 21:27 cchun 阅读(259) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;int main(void){ int stack[20],len,in[10],out[20],count[20]; int *pp=NULL,*p,top,*q,i,n; char strin[10],strout[10]; while(cin>>n) { cin>>strin... 阅读全文
posted @ 2011-04-23 21:23 cchun 阅读(214) 评论(0) 推荐(0) 编辑
摘要: hash的一个变种.构造的树形如上图,不过有一点要记住,就是这道题中,,用next[id]这个指针来作为节点的地址。而通过next[id]->count来存放有这种前缀的单词的个数。。。代码:#include#includeusingnamespacestd;typedefstructTrie{Trie*next[26];intcount;}xixi;... 阅读全文
posted @ 2011-04-23 21:22 cchun 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 这道题没啥好说的,直接飘过……#include#includeusing namespace std;int main(void){int ans,n,b; while(cin>>n){ mapa; for(int i=0;i>b;//用cin就超时了,超1000ms(换成scanf就375ms,,,天哪,差别有这么大么?) a[b]++; if(a[b]==(n+1)/2)... 阅读全文
posted @ 2011-04-23 21:15 cchun 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 题目的意思一开始没有看清楚,题目的意思是: 给你一段序列a1,a2,a3,a4,a5,a6,a7,,然后这段序列可以一直调动第一个数字到最后,例如:a2,a3,a4,a5,a6,a7,a1,…………直到循环了一遍。然后从这么多的序列中求出逆序列最小的一组。注意,序列中的数是从0开始计数的。一开始做还以为给的数字是随意给的呢,笑话,晕了好久。哈哈,切入正题,这道题还是树状数组,但是这道题... 阅读全文
posted @ 2011-04-23 21:11 cchun 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 这道题是树状数组的另一用法,用值去作为数组的下标。具体思路:input:13 1 2 3output:1先以其中一个数假设为a为中心,利用树状数组的优势求出这个数a左边比它自己大的数的个数,再求出这个数a的右边比它自己大的个数,分别记为lmin[a],lmax[a],rmin[a],rmax[a];然后结果就是sum+=lmin[i]*rmax[i]+rmin[i]*rmax[i];外层加上一个... 阅读全文
posted @ 2011-04-23 20:46 cchun 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 树状数组,才刚开始做不久,这是第一道入门题目,可是发觉还是挺难,太抽象了,现在只能先记住模板函数(听好记得,优化成这种模式了)。待如后研究出来了,再补上吧哈。。其实理解不了,却不妨碍做题。如果有大牛看到这篇文章,能够顺便指导下,那就再好不过啦!下面这是从别人那里粘贴过来的(帮助理解):树状数组简介: 树状数组是一种区间求和查询和元素修改的时间复杂度都在logn的线性的数据结构。它支持sig... 阅读全文
posted @ 2011-04-23 20:20 cchun 阅读(205) 评论(0) 推荐(0) 编辑