HDU 1015 Safecracker (DFS)】的更多相关文章

题意:给一个数字n(n<=12000000)和一个字符串s(s<=17),字符串的全是有大写字母组成,字母的大小按照字母表的顺序,比如(A=1,B=2,......Z=26),从该字符串中选出5个字母,使得满足一下条件 v - w^2 + x^3 - y^4 + z^5 = n; 满足条件的可能有多组,请输出字典序最大的一组: 问题 :首先怎么找到满足条件的一组,一组字符串,对于每一个字符我们有两种选择 选||不选 ,然后在对每一个字符去进行这样的判断,然后把我们选好的5个字母在判断是否满足条…
题意:给你一个3*n的格子,中间那行表明的是周围8格(当然左右都没有)的炸弹数量,上下两行都可以放炸弹,问你有几种可能,对mod取模 思路:显然(不),当i - 1和i - 2确定时,那么i的个数一定确定,显然,只要第一列确定,后面全确定了,那么就3种可能,只要遍历到最后,最后一个符合num[n] = pre[n - 1] + pre[n]那么就说明这样排可行.复杂度O(3*n). #include<set> #include<map> #include<stack>…
http://acm.hdu.edu.cn/showproblem.php?pid=1015 题意:给出一个目标值target和一个由大写字母组成的字符串 A-Z分别对应权值1-26 要求从给出的字符串中选出5个字符,它们的权值v,w,x,y,z应符合下列式子 v - w^2 + x^3 - y^4 + z^5 = target 同一个字符只能被选取一次 输出符合要求的5个字符 简单深搜模拟选取操作 # include <stdio.h> # include <string.h>…
Problem Description Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? Input The first line of input contains N, the number of test cases. Each test case begins with an integer 4 <= M <= 20, the number…
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1175 因为题目只问能不能搜到,没问最少要几个弯才能搜到,所以我采取了DFS. 因为与Hdu 1728相比,都要考虑转弯次数,所以在判断转弯的次数上,两者可以相互借鉴. 这一点应该不难想到,在搜索前就应判断两点的值是否相等,以及两点的值中是否有0.如果不相等或其中一值为0,则可以判断是"NO". 时间虽是10000ms,但只是这样,还是超时. 后来又加了一个数组walk[][],用…
把这个写出来是不是就意味着把   http://www.hacker.org/push  这个游戏打爆了? ~啊哈哈哈 其实只要找到一个就可以退出了  所以效率也不算很低的  可以直接DFS呀呀呀呀 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> using…
Problem Description PusherBoy is an online game http://www.hacker.org/push . There is an R * C grid, and there are piles of blocks on some positions. The goal is to clear the blocks by pushing into them. You should choose an empty area as the initial…
Problem Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order. For e…
Friends Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 297    Accepted Submission(s): 127 Problem Description There are n people and m pairs of friends. For every pair of friends, they can cho…
HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tempter of the Bone [从零开始DFS(1)] -DFS四向搜索/奇偶剪枝 HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] -DFS四向搜索变种 HDOJ(HDU).1016 Prime Ring Problem (DFS) [从零开始DFS…