HDU 改革春风吹满地

摘要: “ 改革春风吹满地,不会AC没关系;实在不行回老家,还有一亩三分地。谢谢!(乐队奏乐)”话说部分学生心态极好,每天就知道游戏,这次考试如此简单的题目,也是云里雾里,而且,还竟然来这么几句打油诗。好呀,老师的责任就是帮你解决问题,既然想种田,那就分你一块。这块田位于浙江省温州市苍南县灵溪镇林家铺子村,多边形形状的一块地,原本是linle 的,现在就准备送给你了。不过,任何事情都没有那么简单,你必须首先告诉我这块地到底有多少面积,如果回答正确才能真正得到这块地。发愁了吧?就是要让你知道,种地也是需要AC知识的!以后还是好好练吧...Input输入数据包含多个测试实例,每个测试实例占一行,每行的开始 阅读全文
posted @ 2012-03-28 18:03 江财小子 阅读(628) 评论(0) 推荐(0)

hdu 1205 吃糖果

摘要: HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N<=1000000),第二行是N个数,表示N种糖果的数目Mi(0<Mi<=1000000)。Output对于每组数据,输出一行,包含一个"Yes"或者"No"。Sample Input2 阅读全文
posted @ 2012-03-28 17:55 江财小子 阅读(161) 评论(0) 推荐(0)

HDU 1556 Color the ball

摘要: N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。当N = 0,输入结束。Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。Sample Input 阅读全文
posted @ 2012-03-28 17:54 江财小子 阅读(195) 评论(0) 推荐(0)

POJ 3067 Japan

摘要: Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <= 1000, N <= 1000). K superhighways will be build. Cities on each coast are numbered 1, 2, ... from North to 阅读全文
posted @ 2012-03-28 17:53 江财小子 阅读(216) 评论(0) 推荐(0)

hdu 1541 Stars

摘要: Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the s 阅读全文
posted @ 2012-03-28 17:52 江财小子 阅读(269) 评论(0) 推荐(0)

POJ 2255 Tree Recovery

摘要: Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creations:D/ \/ \B E/ \ \/ \ \A C G//FTo record her trees for future generations, she wrote down two strings 阅读全文
posted @ 2012-03-28 17:51 江财小子 阅读(256) 评论(0) 推荐(0)

HDU(3999)The order of a Tree

摘要: As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:1.insert a key k to a empty tree, then the tree become a tree withonly one node;2.insert a key k to a nonempty tree, if k is less than the root ,insertit to the left sub-tree;else insert k 阅读全文
posted @ 2012-03-28 17:50 江财小子 阅读(445) 评论(0) 推荐(0)

HDU (1710)Binary Tree Traversals

摘要: A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which the vertices of a binary tree can be systematically traversed or ordered. They are preorder, inorder a 阅读全文
posted @ 2012-03-28 17:49 江财小子 阅读(630) 评论(0) 推荐(0)

hdu 1305 Immediate Decodability

摘要: An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at least one bit and no mor 阅读全文
posted @ 2012-03-28 17:48 江财小子 阅读(219) 评论(0) 推荐(0)

二叉搜索树(HDU3791)

摘要: 判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1#include inta[1024],b[1024];voidcta(charc,inti)//这个和下面可以合并一个,用指针传递数组{ if(a[i]==0) {a[i]=c;return;} if(a[i]>c) cta(c,ic) ctb(c,im2?m2:m1;//递归回程,判断树是否一样}intmain(){inti,n; charc[13],s[13]; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); scanf("%s&qu 阅读全文
posted @ 2012-03-28 17:46 江财小子 阅读(1243) 评论(0) 推荐(0)

HDU 1045 Fire Net(DFS)

摘要: Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, East, South, and West 阅读全文
posted @ 2012-03-28 17:43 江财小子 阅读(172) 评论(0) 推荐(0)

HDU 1010 Tempter of the Bone(DFS)

摘要: The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.The maze was a rectangle with sizes N b 阅读全文
posted @ 2012-03-28 17:40 江财小子 阅读(223) 评论(0) 推荐(0)

HDU 2084 数塔

摘要: 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N... 阅读全文
posted @ 2012-03-28 17:39 江财小子 阅读(141) 评论(0) 推荐(0)

HDU 1003 Max Sum

摘要: Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in th... 阅读全文
posted @ 2012-03-28 17:38 江财小子 阅读(174) 评论(0) 推荐(0)

HDU 2037 今年暑假不AC

摘要: 今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)Input输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(n<=100),表示你喜欢看的节目的总数,然后是n行 阅读全文
posted @ 2012-03-28 17:36 江财小子 阅读(139) 评论(0) 推荐(0)

HDU 1009 FatMouse' Trade

摘要: FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in 阅读全文
posted @ 2012-03-28 17:35 江财小子 阅读(131) 评论(0) 推荐(0)

HDU 1425 sort

摘要: 给你n个整数,请按从大到小的顺序输出其中前m大的数。Input每组测试数据有两行,第一行有两个数n,m(0//比用快排做快了200Ms#include #include inta[1000001];intmain(){ //freopen("in.txt","r",stdin); intn,m,k; while(scanf("%d%d",&n,&m)!=EOF) { memset(a,0,sizeof(a)); while(n--) { scanf("%d",&k); a[k+500000] 阅读全文
posted @ 2012-03-28 17:34 江财小子 阅读(163) 评论(0) 推荐(0)

hdu 3784 继续xxx定律

摘要: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数,5,8,4,2称为覆盖数。现在输入n个数字a[i],根据关键数与覆盖数的理论,我们只需要验证其中部分数就可以确定所有数满足xxx定律,输出输入的n个数中的关键数。如果其中有多个关键数的话按照其输入顺序的逆序输出。Input输入数据包含多个用例,每个用例首先包含一个整数n,然后接下来一行有n个整数a[i],其中:1#include #include using namespacestd;boolh[200000];intmain(){ intn,m,i,k,a[503],b[503]; while(s 阅读全文
posted @ 2012-03-28 17:33 江财小子 阅读(268) 评论(0) 推荐(0)

Train Problem I(HDU1022)

摘要: As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes a problem, there is only one railway where all the trains stop. So all 阅读全文
posted @ 2012-03-28 17:32 江财小子 阅读(1478) 评论(0) 推荐(0)

STL的队列和栈简单使用

摘要: #include #include #include #include #include #include using namespace std;int main(){queue Q;stack S;int i;for(i=1;i M //例如 queue Q,q,、、查看是否为空范例 M.empty() 是的话返回1,不是返回0;从已有元素后面增加元素 M.push()输出现有元素的个数 M.size()显示第一个元素 M.front()显示最后一个元素 M.back()清除第一个元素 M.pop()入栈,如例:s.push(x);出栈,如例:s.pop();注意,出栈操作只是删除栈顶元. 阅读全文
posted @ 2012-03-28 17:32 江财小子 阅读(5230) 评论(0) 推荐(1)