08 2015 档案

UVA-1533 Moving Pegs (路径寻找问题)
摘要:DescriptionVenture MFG Company, Inc. has made a game board. This game board has 15 holes and these holes are filled with pegs except one hole. A peg c... 阅读全文

posted @ 2015-08-29 20:38 20143605 阅读(389) 评论(0) 推荐(0)

UVA-10318 Security Panel (DFS+剪枝)
摘要:题目大意:求将一个r*c的按钮矩阵由全部为关变成全部为开的最少按扭次数,每按一次开关能作用到的范围不定。题目分析:开关问题。打眼一看就是BFS+位压缩,但是写出来之后TLE。用DFS不断更新最优解。最坏有2^25种情况,加两个剪枝: 一、每一个开关最多只能影响三行,当第now_r-2行仍然有开关关... 阅读全文

posted @ 2015-08-29 14:26 20143605 阅读(284) 评论(0) 推荐(0)

UVA-10026 Shoemaker's Problem (贪心)
摘要:题目大意:一个鞋匠,有n只鞋要修,修某只鞋的时间ti已知,某只鞋晚修一天要交的罚款fi也已知。现在让找个修鞋顺序使得罚款最少。题目分析:本来想水一下这道题,没想到真的AC啦。后来又查的题解,找的解释。一个比较能说服我的解释是这样的:这个鞋匠不管怎样都要赔本,他每修一只鞋能降低的最大损失是fi/ti,... 阅读全文

posted @ 2015-08-28 14:51 20143605 阅读(149) 评论(0) 推荐(0)

UVA-10020 Minimal coverage(贪心)
摘要:题目大意:在x轴上,给一些区间,求出能把[0,m]完全覆盖的最少区间个数及该情形下的各个区间。题目分析:简单的区间覆盖问题。可以按这样一种策略进行下去:在所有区间起点、长度有序的前提下,对于当前起点,找到可以覆盖下去的最长区间进行覆盖,并不断更新起点,直到覆盖完所有区间。代码如下:# include... 阅读全文

posted @ 2015-08-28 12:39 20143605 阅读(164) 评论(0) 推荐(0)

UVA-1347 Tour
摘要:DescriptionJohn Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts visiting beautiful places. To save money,... 阅读全文

posted @ 2015-08-26 10:35 20143605 阅读(369) 评论(0) 推荐(0)

UVA-10689 Yet another Number Sequence (矩阵二分幂模板)
摘要:题目大意:已知递推公式和边缘值,求某项的最后m(0 2 # include 3 # include 4 # include 5 using namespace std; 6 struct matrix 7 { 8 int r,c,m[3][3]; 9 matrix(int _r,in... 阅读全文

posted @ 2015-08-19 07:58 20143605 阅读(232) 评论(0) 推荐(0)

UVA-11149 Power of Matrix(矩阵二分幂)
摘要:题目大意:给一个n阶方阵,求A1+A2+A3+......Ak。题目分析:令F(k)=A1+A2+A3+......Ak。当k为偶数时,F(k)=F(k/2)*(E+Ak/2),k为奇数时,F(k)=F(k/2)*(E+Ak/2)+Ak。证明这两条公式也很简单,把这两条公式展开就行了。根据公式,递归... 阅读全文

posted @ 2015-08-18 17:48 20143605 阅读(583) 评论(0) 推荐(0)

UVA-10655 Contemplation! Algebra (矩阵)
摘要:题目大意:给出a+b的值和ab的值,求a^n+b^n的值。题目分析:有种错误的方法是这样的:利用已知的两个方程联立,求解出a和b,进而求出答案。这种方法之所以错,是因为这种方法有局限性。联立之后会得到一个二元一次方程,只有当该方程有实数解确切的说是当某个数据满足该方程有实数解时,这种方法得到的结果才... 阅读全文

posted @ 2015-08-18 13:55 20143605 阅读(467) 评论(0) 推荐(0)

POJ-2415 Hike on a Graph (BFS)
摘要:Description"Hike on a Graph" is a game that is played on a board on which an undirected graph is drawn. The graph is complete and has all loops, i.e. ... 阅读全文

posted @ 2015-08-17 17:11 20143605 阅读(284) 评论(0) 推荐(0)

POJ-1475 Pushing Boxes (BFS+优先队列)
摘要:DescriptionImagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move nort... 阅读全文

posted @ 2015-08-17 14:57 20143605 阅读(640) 评论(1) 推荐(1)

HDU-1226 超级密码 (BFS+剪枝)
摘要:Problem DescriptionIgnatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息:密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0 2 # include 3 #... 阅读全文

posted @ 2015-08-16 15:57 20143605 阅读(235) 评论(0) 推荐(0)

POJ-3414 Pots (BFS)
摘要:DescriptionYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i ... 阅读全文

posted @ 2015-08-16 15:43 20143605 阅读(201) 评论(0) 推荐(0)

POJ-3087 Shuffle'm Up (模拟)
摘要:DescriptionA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks... 阅读全文

posted @ 2015-08-16 15:40 20143605 阅读(147) 评论(0) 推荐(0)

POJ-1129 Channel Allocation (DFS)
摘要:DescriptionWhen a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a stron... 阅读全文

posted @ 2015-08-16 15:33 20143605 阅读(197) 评论(0) 推荐(0)

POJ-3083 Children of the Candy Corn (BFS+DFS)
摘要:DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-... 阅读全文

posted @ 2015-08-16 15:23 20143605 阅读(184) 评论(0) 推荐(0)

HDU-1429 胜利大逃亡(续) (BFS+状态压缩)
摘要:Problem DescriptionIgnatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)……这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx,sy)的位置,离开地牢的门在(e... 阅读全文

posted @ 2015-08-14 16:35 20143605 阅读(451) 评论(0) 推荐(0)

POJ-3894 迷宫问题 (BFS+路径还原)
摘要:定义一个二维数组: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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程... 阅读全文

posted @ 2015-08-14 07:53 20143605 阅读(780) 评论(0) 推荐(0)

HDU-4471 Yet Another Multiple Problem (BFS+路径还原)
摘要:Problem DescriptionThere are tons of problems about integer multiples. Despite the fact that the topic is not original, the content is highly challeng... 阅读全文

posted @ 2015-08-13 17:08 20143605 阅读(138) 评论(0) 推荐(0)

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 ... 阅读全文

posted @ 2015-08-13 09:51 20143605 阅读(129) 评论(0) 推荐(0)

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... 阅读全文

posted @ 2015-08-13 09:32 20143605 阅读(118) 评论(0) 推荐(0)

POJ-2676 Sudoku (DFS)
摘要:Sudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cell... 阅读全文

posted @ 2015-08-13 09:14 20143605 阅读(159) 评论(0) 推荐(0)

POJ-2251 Dungeon Master (BFS模板题)
摘要:You 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.... 阅读全文

posted @ 2015-08-13 09:08 20143605 阅读(419) 评论(0) 推荐(0)

POJ-3635 Full Tank? (记忆化广搜)
摘要:DescriptionAfter going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities ... 阅读全文

posted @ 2015-08-13 08:52 20143605 阅读(241) 评论(0) 推荐(0)

POJ-1753 Flip Game (BFS+状态压缩)
摘要:DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and ... 阅读全文

posted @ 2015-08-13 08:04 20143605 阅读(309) 评论(0) 推荐(0)

UVA-701 The Archeologists' Dilemma (数论)
摘要:题目大意:给了一个2^E的前缀n,已知前缀n的位数不到2^E的位数的一半,找出满足条件的最小E。题目解析:设2^E为i位数,则有n*10^i# include# include# include# includeusing namespace std;void work(unsigned n){ ... 阅读全文

posted @ 2015-08-09 13:49 20143605 阅读(394) 评论(0) 推荐(0)

UVA-10061 How many zero's and how many digits ? (数论)
摘要:题目大意:让求n!在base进制下的位数以及末尾0的连续个数。题目分析:一个m位的b进制数N,最小是b^(m-1),最大不超过b^m,即b^(m-1)≤N# include# include# include# include# includeusing namespace std;const in... 阅读全文

posted @ 2015-08-09 11:02 20143605 阅读(471) 评论(0) 推荐(0)

UVA-11728 Alternate Task
摘要:题目大意:给一个数s(s 2 # include 3 # include 4 # include 5 # include 6 using namespace std; 7 int ans[1005]; 8 sets; 9 void init()10 {11 set::iterator it;... 阅读全文

posted @ 2015-08-09 10:07 20143605 阅读(213) 评论(0) 推荐(0)

UVA-11490 Just Another Problem
摘要:题目大意:一个由p*q个点组成的pxq点阵(构成一个矩形)。从内层点中拿走两块正方形上的所有点,这两块正方形要边长相等,在位置上关于中线对称,并且还要使每一个正方形的上下左右剩余的点的层数相等。现在告已知拿走以后剩余的点的个数s,求可能拿走了多少个点。题目分析:当拿走了2n^2个点时,根据题设中的条... 阅读全文

posted @ 2015-08-09 09:53 20143605 阅读(219) 评论(0) 推荐(0)

UVA-10127 Ones (数论)
摘要:题目大意:给一个数n,找出一个各位全是1的最小的十进制数,使得n能整除这个数。只输出最小位数。题目分析:纯粹是数论,暴力。代码如下:# include# include# include# includeusing namespace std;int solve(int n){ int cnt... 阅读全文

posted @ 2015-08-09 09:34 20143605 阅读(216) 评论(0) 推荐(0)

UVA-10710 Skyscraper Floors (找规律+幂取模)
摘要:题目大意:题目中给了一种数的定义,根据定义,让判断一个给定的数是不是这种数。题中叫这种数为吉米数,定义如下:对序列1,2,3,,,,n,做n-1次SF变换(对该变换的解释在下文),如果能得到原序列,则n为吉米数。SF变换:若n为偶数,以n=10为例,一次SF变换是这样的 1,2,3,4,5,6... 阅读全文

posted @ 2015-08-06 22:44 20143605 阅读(321) 评论(0) 推荐(0)

UVA-10539 Almost Prime Numbers
摘要:题目大意:这道题中给了一种数的定义,让求在某个区间内的这种数的个数。这种数的定义是:有且只有一个素因子的合数。题目分析:这种数的实质是素数的至少两次幂。由此打表——打出最大区间里的所有这种数构成的表即可。代码如下: 1 # include 2 # include 3 # include 4 # in... 阅读全文

posted @ 2015-08-06 19:31 20143605 阅读(188) 评论(0) 推荐(0)

UVA-10692 Huge Mods
摘要:题目大意:计算a1^a2^a3^a4......^an模m的值。题目解析:幂取模运算的结果一定有周期。一旦找到周期就可把高次幂转化为低次幂。有降幂公式 (a^x)%m=(a^(x%phi(m)+phi(m))%m x>=phi(m)其中,phi()函数是欧拉函数。代码(代码有瑕疵)如... 阅读全文

posted @ 2015-08-06 14:25 20143605 阅读(615) 评论(3) 推荐(1)

HDU-1163 Eddy's digital Roots(九余数定理)
摘要:Eddy's digital RootsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5183Accepted Submission(s): 28... 阅读全文

posted @ 2015-08-04 15:44 20143605 阅读(563) 评论(0) 推荐(0)

POJ-2689 Prime Distance (两重筛素数,区间平移)
摘要:Prime DistanceTime Limit:1000MSMemory Limit:65536KTotal Submissions:13961Accepted:3725DescriptionThe branch of mathematics called number theory is abo... 阅读全文

posted @ 2015-08-04 09:12 20143605 阅读(212) 评论(0) 推荐(0)