题意:给出一个n*n的矩阵,旋转每一圈数字,求出对角线可能的最大值,以及转到最大时的最小距离. 只要分析每一层就可以了,本来想用地址传递二维数组,发现行不通,改了一下就行了. 这里有个坑,比如: 1 1 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 很明显最大的就是将一个9转到矩阵角,而这里更新最大值时很容易把另一种情况屏蔽掉,从而错过了更少步骤达到最大值的方法. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blo…
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Alice was felling into a cave. She found a strange door with a number square m…
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1836    Accepted Submission(s): 580 Problem Description Alice was felling into a cave. She found a strange door with a numbe…
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 290    Accepted Submission(s): 60 Problem Description Alice was felling into a cave. She found a strange door with a number s…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 题目大意:给定一个方形矩阵,边长为3-10的奇数.每一圈的数字可以沿着顺时针方向和逆时针方向旋转,求使得矩阵主对角线和反对角线和最大时的数以及需要旋转的最小步骤. Sample Input 5 9 3 2 5 9 7 4 7 5 4 6 9 3 9 3 5 2 8 7 2 9 9 4 1 9 0   Sample Output 72 1 分析:简单的模拟.分别计算每一圈旋转后的四个角的值最大需…
题意:按字母顺序排列成n型,简单的模拟题. 当字母排到z时从a开始重新排起. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.csdn.net/hcbbt * File: a.cpp * Create Date: 2013-09-08 12:31:36 * Descripton: simulate */ #include <cstdio> #define rep(i, n) for (int i…
题意:给出一个偶数(不论正负),求出两个素数a,b,能够满足 a-b=x,素数在1e6以内. 只要用筛选法打出素数表,枚举查询下就行了. 我用set储存素数,然后遍历set里面的元素,查询+x后是否还是素数. 注意,偶数有可能是负数,其实负数就是将它正数时的结果颠倒就行了. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.csdn.net/hcbbt * File: 10.cpp * Create Date:…
题意:linji的仓鼠丢了,他要找回仓鼠,他在房间0放了一块奶酪,按照抓鼠手册所说,这块奶酪可以吸引距离它D的仓鼠,但是仓鼠还是没有出现,现在给出一张关系图,表示各个房间的关系,相邻房间距离为1,而且图中没有回路,每个房间都是联通的,求仓鼠可能出现的房间的数量. 很容易的dfs,50000个房间数据量比较大,用数组难以保存,于是用vector储存关系表.遍历过去,遍历过几个房间,那剩下的就是仓鼠可能出现的房间数了. 代码: /* * Author: illuz <iilluzen[at]gmai…
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 654 Accepted Submission(s): 190 Problem Description Alice was felling into a cave. She found a strange door with a number squar…
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 695    Accepted Submission(s): 204 Problem Description Alice was felling into a cave. She found a strange door with a number…