自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 HDU 1022 Train Problem I

Problem DescriptionAs 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

2015-11-10 15:55:28 260

原创 HDU 1870 愚人节的礼物

Problem Description四月一日快到了,Vayko想了个愚人的好办法——送礼物。嘿嘿,不要想的太好,这礼物可没那么简单,Vayko为了愚人,准备了一堆盒子,其中有一个盒子里面装了礼物。盒子里面可以再放零个或者多个盒子。假设放礼物的盒子里不再放其他盒子。用()表示一个盒子,B表示礼物,Vayko想让你帮她算出愚人指数,即最少需要拆多少个盒子才能拿到礼物。 

2015-11-09 20:25:53 437

原创 HDU 1276 士兵队列训练问题

Problem Description 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。Input 本题有多个测试数据组,第一行

2015-11-09 16:51:56 379

原创 UVa 11988 Broken Keyboard (a.k.a. Beiju Text) (链表)

Broken Keyboard (a.k.a. Beiju Text)You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" k

2015-11-08 20:26:31 347

原创 UVa 442 Matrix Chain Multiplication(栈)

题意:输入n个矩阵的维度和一些矩阵链乘表达式,输出乘法的次数。假定A和m*n的,B是n*p的,那么AB是m*p的,乘法次数为m*n*p 。如果不能相乘输出error。Input SpecificationInput consists of two parts: a list of matrices and a list of expressions.The firs

2015-11-07 21:11:43 280

原创 UVa 210 Concurrency Simulator(双端队列)

题意:你的任务是模拟n个程序(按输入顺序编号为1~n)的并行执行。每个程序包含不超过25条语句,格式一共有5种:var = constant (赋值):print var (打印):lock:unlock:end。变量用单个小写字母表示,初始为0,为所有程序公有(因此在一个程序里对某个变量赋值可能会影响另一个程序) 。常数是小于100的非负整数。每个时刻只能有一个程序处于运行状态,其他

2015-11-07 20:09:51 441

原创 UVa 514 Rails(栈)

题目链接:(http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=7&page=show_problem&problem=455)题目描述:某城市有一个火车站,有n节车厢从A方向驶入车站,按进站的顺序编号为1-n.你的任务是判断是否能让它们按照某种特定的顺序进入B方向的铁轨

2015-11-02 12:40:09 829 1

原创 POJ 3669 Meteor Shower(预处理 + BFS)

DescriptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find

2015-10-29 20:17:26 763

原创 POJ 3050 Hopscotch

DescriptionThe cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5x5 rectilinear grid of digits paral

2015-10-26 19:21:06 273

原创 POJ 3187 Backward Digit Sums(DFS)

DescriptionFJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer

2015-10-21 19:19:55 213

原创 POJ 3617 Best Cow Line(字典序最小问题)

DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges.T

2015-10-20 21:00:32 340

原创 POJ 1979 Red and Black(BFS or DFS)

DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent til

2015-10-19 19:18:38 239

原创 POJ 2386 Lake Counting (DFS or BFS)

DescriptionDue to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains

2015-10-18 18:07:55 274

原创 POJ 2393 Yogurt factory(贪心 or DP)

DescriptionThe cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it w

2015-10-15 20:05:29 453

原创 poj 1017 Packets

Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parc

2015-10-13 20:53:14 267

原创 POJ 1862 Stripies

DescriptionOur chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an Englis

2015-10-09 20:57:11 320

原创 POJ 3262 Protecting the Flowers

DescriptionFarmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eatin

2015-10-09 16:25:54 276

原创 POJ 3190 Stall Reservations (选择不相交区间)

DescriptionOh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and

2015-10-08 20:27:52 1285

原创 POJ 2376 Cleaning Shifts(区间覆盖问题)

DescriptionFarmer John is assigning some of his N (1 Each cow is only available at some interval of times during the day for work on cleaning. Any cow that is selected for cleaning duty will work

2015-09-30 12:40:39 471 2

原创 poj 3126 Prime Path(BFS)

DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It i

2015-09-18 16:56:27 247

原创 POJ 3009 Curling 2.0 (DFS)

DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a squa

2015-09-17 15:29:32 276

原创 POJ 2251 Dungeon Master (BFS)

DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one un

2015-09-10 15:06:15 196

原创 POJ 1321 棋盘问题 (DFS)

Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n

2015-09-06 19:07:42 472

原创 POJ 3278 Catch That Cow (BFS)

DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤

2015-09-04 21:37:07 232

原创 POJ 3984 迷宫问题(BFS or DFS)

Description定义一个二维数组: int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数

2015-09-02 12:26:16 396

转载 BFS

宽度优先搜索(BFS,Breadth-First Search),也是搜索的手段之一。它与深度优先搜索类似,从某个状态出发探索所有可以到达的状态。 与深度优先搜索的不同之处在于搜索的顺序,宽度优先搜索总是先搜索距离初始状态近的状态。对于同一个状态,宽度优先搜索只经过一次,因此复杂度为O(状态数 X 转移的方式)。 宽度优先搜索利用了队列。搜索时首先将初始状态添加到队列里,此后从队列的最前端不断取

2015-09-02 10:10:01 222

转载 DFS

深度优先搜索(DFS,Depth-First Search)是搜索的手段之一。它从某个状态开始,不断地转移状态直到无法转移,然后回退到前一步的状态,继续转移到其他状态,如此不断重复,直到找到最终的解。深度优先搜索(隐式的)利用了栈进行计算,因此采用递归函数实现比较简单。

2015-09-02 10:01:23 202

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除