第一篇博客,格式惨不忍睹.首先感谢一下鼓励我写博客的大佬@Titordong其次就是感谢一群大佬激励我不断前行@Chunibyo@Tiancfq因为室友tanty强烈要求出现,附上他的名字. Catch That Cow(POJ3278) BFS入门题,然鹅我还是WA了四五发,因为没注意,位置0是可以访问的.再者就是初始位置在push之后,要标记为已经访问. 图片挺不错,我们地大(武汉)的旖旎风光,放松一下. 题目链接:POJ3278 Description Farmer John has be…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=1104 注意这里定义的取模运算和计算机的%是不一样的,这里的取模只会得到非负数. 而%可以得到正数和负数. 所以需要 a mod b = (a % b + b) % b 这样转换得到. 并且,由于新的N可以很大,所以我们每一步都要取%,而且最后要mod k,正常来说每步都%k就行了,但是由于其中的一个操作是N%m,所以我们每一步就不能%k了(%k%m混用会导致%出来的答案错误),而要%(k *m)(其实%(k,…
D - 广搜 基础 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u Submit Status Description BackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move kni…
C - 广搜 基础 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the…
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14539 Accepted: 8196 Description The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-dig…
容斥原理 A Number Sequence 题意:给出n个数,b1,b2,b3……bn,构造n个数,a1,a2,……an(ai>1),使得a1*a2*a3……an=b1*b2……bn 分析:容易想到的是将bi分解质因数,然后记录每个质因数的个数.那么题目变成:对于(每个质因数个数为m个划分到n个不同的容器的方案数),注意ai>1,所以没有某个数没有质因数.记f(n)为n个数字可能有1的方案数,g(n)为n个数字一定没有1的方案数.则,得到听说这是二项式反演? #include <bit…
Problem Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one…
前言 之前把一些LeetCode题目的思路写在了本子上,现在把这些全都放到博客上,以后翻阅比较方便. 题目 99.Recover Binary Search Tree 题意 Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. 恢复两个因错误而导致的左右子树. 思路 通常我们的做法是,根据BST的特质,可以用中序遍历来检…
一.题目回顾 题目链接:逃离迷宫 Problem Description 给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去.令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中,不能转太多弯了,否则她会晕倒的.我们假定给定的两个位置都是空地,初始时,…
Problem Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one…