dfs
lyyy.
这里介绍不了我
展开
-
L2-016. 愿天下有情人都是失散多年的兄妹-dfs
L2-016. 愿天下有情人都是失散多年的兄妹时间限制 200 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 陈越呵呵。大家都知道五服以内不得通婚,即两个人最近的共同祖先如果在五代以内(即本人、父母、祖父母、曾祖父母、高祖父母)则不可通婚。本题原创 2018-03-18 18:00:26 · 235 阅读 · 0 评论 -
整数分解为若干项之和 - 天梯赛练习 -dfs
整数分解为若干项之和将一个正整数N分解成几个正整数相加,可以有多种分解方法,例如7=6+1,7=5+2,7=5+1+1,…。编程求出正整数N的所有整数分解式子。原创 2017-03-15 15:54:18 · 697 阅读 · 0 评论 -
L2-006. 树的遍历 -天梯赛练习题
L2-006. 树的遍历 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。原创 2017-03-09 11:57:50 · 394 阅读 · 0 评论 -
L1-006 连续因子-团体程序设计天梯赛-练习
L1-006. 连续因子一个正整数N的因子中可能存在若干连续的数字。例如630可以分解为3*5*6*7,其中5、6、7就是3个连续的数字。给定任一正整数N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。输入格式: 输入在一行中给出一个正整数N(1<N<231)。 输出格式: 首先在第1行输出最长连续因子的个数;然后在第2行中按“因子1*因子2*……*因子k”的格式输出最小的连续因子序列,其中因子按递增顺序输出,1不算在内。输入样例:630输出样例:35*6*7解题思路原创 2017-03-02 21:22:23 · 376 阅读 · 0 评论 -
CodeForces 586D Phillip and Trains -dfs
Phillip and TrainsThe mobile application store has a new game called "Subway Roller".The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows原创 2016-11-20 14:12:00 · 365 阅读 · 0 评论 -
网络流之最大流-Ford-Fullkerson算法 DFS && BFS
1、最大流的个人理解举例来说就是一个河流网,从a城市到b城市的河道中有的宽有的窄,问最大水流量能是多少,这个主要取决于这条路上的最窄的河道。2、Ford-Fullkerson算法 (挑战程序设计竞赛 P210)由于有很多条河道可选,例如 路径一:a—c—d—b 或者 路径二:a—c—f—b,按上面的想法,可能出现先走路径1和先走路径2产生的结果不一样,这时候可能是因为a-c这条原创 2016-10-06 19:24:14 · 1932 阅读 · 0 评论 -
poj 3411 Paid Roads -dfs
Paid RoadsA network of m roads connects N cities (numbered from 1 to N). There may be more than one road connecting one city with another. Some of the roads are paid. There are two ways to pay for travel on a paid road i from city ai to city bi:•in advan原创 2016-10-28 21:56:23 · 865 阅读 · 0 评论 -
黑白图像
题目描述输入一个n*n的黑边图像(1表示黑色,0表示白色)任务是统计其中八连块的个数。八连块:如果两个黑色格子有公共边或者是公共顶点,则这两个格子属于一个八连块。输入n*n的黑白图像。输出八连块的个数样例输入6及如图图像样例输出3解题思路 用原创 2015-11-25 19:06:28 · 615 阅读 · 0 评论 -
poj1190 生日蛋糕 -dfs
生日蛋糕7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要求Ri > Ri+1且Hi > Hi+1。 由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积Q最小。 令Q = Sπ 请编程对给出的N和M,找出蛋糕的制作方案(适当的Ri和Hi的值),使S最小。 (除Q外,以上所有数据皆为正整数)原创 2016-09-27 16:59:00 · 526 阅读 · 0 评论 -
poj 2531 Network Saboteur
A university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order to minimize traffic between parts.A disgruntled computer science stud原创 2016-09-03 10:38:39 · 310 阅读 · 0 评论 -
hdu1078 FatMouse and Cheese 搜索dfs&dp
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid between 0 and 100 blocks of cheese in a hole原创 2016-09-13 13:54:50 · 317 阅读 · 0 评论 -
poj 2697 A Board Game-dfs
Dao was a simple two-player board game designed by Jeff Pickering and Ben van Buskirk at 1999. A variation of it, called S-Dao, is a one-player game. In S-Dao, the game board is a 4 * 4 square with 16 cells. There are 4 black stones and 4 white stones plac原创 2016-08-30 18:12:26 · 570 阅读 · 0 评论 -
poj1176 Party Lamps dfs优化+规律枚举
To brighten up the gala dinner of the IOI'98 we have a set of N coloured lamps numbered from 1 to N. The lamps are connected to four buttons: button 1 -- when this button is pressed, all the lamps change their state: those that are ON are turned OFF and原创 2016-08-19 16:45:20 · 920 阅读 · 0 评论 -
vijos-p1599 货币 -记忆化搜索
描述在某个神秘的星球上有一种货币,它有一种奇怪的兑换规则你有且仅有一枚面值为n的金币,你可以去银行进行兑换,也可以不兑换如果去银行兑换,兑换的规则是这样的:用面值为a的金币去兑换可以换到a/2,a/3,a/4这三枚硬币(如果是小数则截尾取整),你可以兑换多次读入n输出你最后最多能拥有的钱数w每个测试点中有T组数据格式输入格式一个数T表示该原创 2016-07-22 08:16:01 · 413 阅读 · 0 评论 -
hdu-1010Tempter of the Bone-dfs
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1010Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThe dogg原创 2016-08-03 15:14:54 · 271 阅读 · 0 评论 -
PAT甲级练习题 -Counting Leaves (30) -dfs
1004. Counting Leaves (30)时间限制 400 ms内存限制 65536 kB代码长度限制 16000 B判题程序 Standard 作者 CHEN, YueA family hierarchy is usually presented by a pedigree tr原创 2018-04-03 12:49:27 · 260 阅读 · 0 评论