4.3.6 N皇后问题
摘要:Problem Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input 共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。 Output 共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。 Sample Input1850 Sample Output19210 ...
阅读全文
posted @
2013-01-03 19:55
cssystem
阅读(236)
推荐(0)
4.3.5 Sticks (POJ1011)
摘要:Problem DescriptionGeorge 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 they were originally. Please help him and design a program wh
阅读全文
posted @
2013-01-02 12:05
cssystem
阅读(140)
推荐(0)
4.3.7 Sequence two
摘要:Problem Description Search is important in the acm algorithm. When you want to solve a problem by using the search method, try to cut is very important.Now give you a number sequence, include n (<=100) integers, each integer not bigger than 2^31, you want to find the first P subsequences that is
阅读全文
posted @
2012-12-29 23:03
cssystem
阅读(176)
推荐(0)
4.3.3 蜘蛛牌
摘要:Problem Description蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么这些牌也 跟着一起移动,游戏的目的是将所有的牌按同一花色从小到大排好,为了简单起见,我们的游戏只有同一花色的10张牌,从A到10,且随机的在一行上展开,编 号从1到10,把第i号上的牌移到第j号牌上,移动距离为abs(i-j),现在你要做的是求出完成游戏的最小移动距离。 Input 第一个输入数据是T,表示数据的组数。每组数据有一行,10个输入数据,数据的范围是[1,...
阅读全文
posted @
2012-12-28 17:56
cssystem
阅读(244)
推荐(0)
4.3.1 Tempter of the Bone
摘要: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, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.The maze was a rect
阅读全文
posted @
2012-12-27 23:26
cssystem
阅读(154)
推荐(0)
4.3.4 Sudoku Killer
摘要:Problem Description 自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。所以全球人民前仆后继,为了奖品日夜训练茶饭不思。当然也包括初学者linle,不过他太笨了又没有多少耐性,只能做做最最基本的数独题,不过他还是想得到那些奖品,你能帮帮他吗?你只要把答案告诉他就可以,不用教他是怎么做的。数独游戏的规则是这样的:在一个9x9的方格中,你需要把数字1-
阅读全文
posted @
2012-12-27 22:21
cssystem
阅读(155)
推荐(0)
4.3.2 Prime Ring Problem
摘要:Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1. Input n (0 < n < 20). O...
阅读全文
posted @
2012-12-26 22:57
cssystem
阅读(152)
推荐(0)