任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6341 Problem J. Let Sudoku Rotate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1363    Accepted Submission(s): 717 Problem Description Sudoku i…
题目:有一个4*4*4*4的数独,每一横每一竖每一个小方块中都无重复的字母,即都为0-9,A-F..有一个已经填好的数独,若干个4*4的方块被逆时针拧转了若干次,问拧转回来至少需要多少次. 分析:很明显的一道深授暴力题 , 一开始不知道是怎么收才好 , 那时候考虑说假如同一行或者同一列都有区域要反转 , 我该怎么找 , 后来看了题解后发现 , 我只要保证每次旋转后 , 该区域与此前的区域是满足数独的就好 , 子问题的不重复不会影响到大问题的不重复 .深搜索的能力需要加强 #include<bit…
题目传送门 题意: 给你16个16宫格的数独,里面是0~F,你可以逆时针旋转里面的每个16宫格 问你它是从标准数独逆时针旋转多少次得到? 思路: 可以知道每个16宫已经是标准的了,接下来只要考虑每行.每列就行了 那么我们在dfs中就可以用两个行列两个数组来标记每个数字出现的次数, 大于1则不行 另外此时是逆时针来的,那么你就要顺时针回去 逆一次等于顺3次 参考博客:https://www.cnblogs.com/zquzjx/p/10326048.html 代码: #include<bits/s…
Problem J. Let Sudoku Rotate Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Sudoku is a logic-based, combinatorial number-placement puzzle, which is popular around the w…
题意:有N个主武器(MW)和M个副武器(SW),每个武器都有自己的S值,和K个附加属性xi.要选取一对主副武器搭配,搭配后获得的性能由该公式得出: 求获得最大的性能为多少. 分析:由于|xm - xs| = max (xm - xs, xs -xm) .所以每种武器如果选择,则其属性xi在最后贡献中只有正负两种状态.那么对于每一种武器,其对最终贡献可能有2^K中组合, 若主武器的一种组合为S,则其选取的副武器的组合即为S的补集.所以对每一种组合S,枚举每个武器在该组合下的贡献并记录最大值. 最后…
题目大意:有两类武器(主武器和副武器),每类有若干把,每把武器都有一个基础属性S,以及k个附加属性,让你选一把主武器M和一把副武器S,使得最大. 显然后面的和式是一个k维的曼哈顿距离,带绝对值符号不好算,因此要想办法把绝对值去掉.由于两点任意一个维度(设其值分别为a,b)的曼哈顿距离要么是a-b,要么是b-a,符号总是相反的,因此可以二进制枚举每一维的正负号,对主武器取最大值,对副武器取最小值,两者相减就可以得到最大的曼哈顿距离.中间可能有的值不合法,但不合法的值一定不是最优值,因此可以忽略.…
题意:给你\(m\)个长度为\(n\)的二进制数,求最少选多少个使它们\(|\)运算后所有位置均为\(1\),如果不满足条件,则输出\(-1\). 题解:这题\(n\)的范围很大,所以我们先用\(string\)读,然后再转化为\(bitset\),之后再直接dfs爆搜,对于满足条件的维护一个最小值即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath>…
题意:从S走到D,能不能恰好用T时间. 析:这个题时间是恰好,并不是少于T,所以用DFS来做,然后要剪枝,不然会TEL,我们这样剪枝,假设我们在(x,y),终点是(ex,ey), 那么从(x, y)到(ex, ey),要么时间正好是T-你已经走过的时间,要么要向别的地方先拐一下,以凑出这个正好时间,既然要拐一下,那么一定要回来, 所以时间肯定得是偶数,要不然完不成(回不来), 所以(t - abs(ex-x) - abs(ey-y) - cnt ),如果是奇数就剪枝.然而用C++交就TLE,用G…
Problem J. Let Sudoku Rotate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Sudoku is a logic-based, combinatorial number-placement puzzle,…
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…
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…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 58766    Accepted Submission(s): 15983 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
做了很久还是参考了别人的答案orz,其实也不难啊.我要开始学一下怎么写搜索了... 题目链接:poj2676 Sudoku 题解:暴力搜索,DFS每个空白格子所放数字. #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<vector> using namespace std; ][];//row_f[i][j]=1表示第i行已经放了…
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…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake…
HDU 1501 Zipper [DFS+剪枝] 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…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5887 题解:这题一看像是背包但是显然背包容量太大了所以可以考虑用dfs+剪枝,贪心得到的不一定是正确答案.当然这题还可以用背包来写,其实这就用到了dp的一些优化就是存状态,递推过程中有些状态是多余的没必要计算这样就可以大大减少空间的利用和时间的浪费 第一份是dfs+剪枝的写法第二份是背包+map存状态的写法. #include <iostream> #include <cstri…
#define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web Board ProblemSet Standing Status Statistics   Problem J: 动物爱好者 Problem J: 动物爱好者 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 509  Solved: 376[Submit][Stat…
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two. From the theorem, we know that a3 + b3 = c3 has no positive i…
题目传送门 /* 题意:告诉一个区间[L,R],问根节点的n是多少 DFS+剪枝:父亲节点有四种情况:[l, r + len],[l, r + len - 1],[l - len, r],[l - len -1,r]; */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> using namespace std;…
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem J: 求个最大值 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 871  Solved: 663[Submit][Status][Web Board] Description 定义MaxValue类,用于求一系列非零整数的最大值.其中: 1. 数据成员elements用于存储所有输入的非零整数. 2. void append(int)用于向elements中添加一个新数据. 3. int getMax()用于求出elements中的…
Problem J. Journey with Pigshttp://codeforces.com/gym/241680/problem/J考察排序不等式算出来单位重量在每个村庄的收益,然后生序排列猪的重量也生序排列此时价值最大 #include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cmath> #include<ctime>…
Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest possible number of circles with diameter y out of a stripe of length x and width y. Input The only line of input consists of two positive real number…
简单dfs,差分一下A数组和建出字典树能写得更方便,若不这么做代码时就会像我一样难受. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int N = 100003; int a[13][N], n, m, k, A[13], pos[13][N]; ll dfs(int tmp, int l, int r, i…
题目:Problem J. TerminalInput file: standard inputOutput file: standard inputTime limit: 2 secondsMemory limit: 256 mebibytesN programmers from M teams are waiting at the terminal of airport. There are two shuttles at the exitof terminal, each shuttle…
Problem J: 连分数 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2723  Solved: 801[Submit][Status][Web Board] Description 一个高为n的连分数定义为 . 给出2个数,一个用p/q的方式表达,另一个用高度为n的连分数来表示,请你判断他们是否相等. Input 输入有多组,每组包含两部分用来表示两种形式的分数:第一部分是p和q(1 ≤ q ≤ p ≤ 10^18),表示分数p/q:然后是一…
6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题] 代码: //1012-6343-数学 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<bitset&g…
Problem J: 幻化 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 18 Solved: 3 [Submit][Status][Web Board] Description 遇见你是我一世的春暖花开, 从此清风明月浩瀚星海. 不论结局,很高兴认识你. 她给了他一个长度为n的整数序列a[],他还给了她另外一个长度为n的整数序列b[],现在他想通过每次交换a[i],a[j]使序列a变成b,但是每次交换的代价是|j-i|. 请问最少的代价是多少呢?…