HDU 5937 Equation(DFS+剪枝)】的更多相关文章

Equation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 92    Accepted Submission(s): 24 Problem Description Little Ruins is a studious boy, recently he learned addition operation! He was rewa…
题目链接 Equation 给定1-9这9个数字各自的卡片数,求能构成形如$i + j = k$的等式个数 等式中$i,j,k$必须都为个位数 若两个等式中$i,j,k$不完全相等,则这两个等式为不同的等式. 打表发现符合题意的等式有36个 那么通过01搜索状态数为$2^{36}$ TLE 我们求出若答案为36,每张卡片需求量$f[i]$ 每次读入$a[i]$的时候 若对$i(1 <= i <= 9)$, 都有$a[i] >= f[i]$ 则直接输出36 DFS的时候x为当前的等式用/不…
题意: 有1~9数字各有a1, a2, -, a9个, 有无穷多的+和=. 问只用这些数字, 最多能组成多少个不同的等式x+y=z, 其中x,y,z∈[1,9]. 等式中只要有一个数字不一样 就是不一样的 思路: 计算下可以发现, 等式最多只有36个. 然后每个数字i的上界是17-i个 可以预先判掉答案一定是36的, 然后直接暴力搜索每个等式要不要就好了. 注意剪枝即可 ; int a[maxn]; bool flag36; int ans; struct Equation { int x, y…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1072 思路:深搜每一个节点,并且进行剪枝,记录每一步上一次的s1,s2:如果之前走过的时间小于这一次, 就说明有更短的:路径,所以就不用继续遍历下去. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ][],step[][],tim[][],m,n,ans; ][]={{-…
题目链接 problem description Little Ruins is a studious boy, recently he learned addition operation! He was rewarded some number bricks of 11 to 99 and infinity bricks of addition mark '+' and equal mark '='. Now little Ruins is puzzled by those bricks b…
<题目链接> 题目大意:在一个棋盘上给定一个起点和终点,判断这两点是否能通过连线连起来,规定这个连线不能穿过其它的棋子,并且连线转弯不能超过2次. 解题分析:就是DFS从起点开始搜索,只不过搜索的时候需要记录当前的方向和已经转弯的次数,然后通过题目给定的限制条件进行搜索,判断是否存在从起点到终点转弯次数不超过2次的连线.同时,在转弯次数达到两次的时候,我们可以对搜索树进行可行性剪枝,直接判断转弯两次后,该点与终点是否在同一条直线上,从而减少搜索时间. #include <bits/std…
Collect More Jewels Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6739    Accepted Submission(s): 1564 Problem Description It is written in the Book of The Lady: After the Creation, the cruel…
Sticks Problem Description George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long the…
Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 539    Accepted Submission(s): 204 Problem Description A clique is a complete graph, in which there is an edge between every pair…
Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Given a specified total t and…