Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n 2 #include 3 int n,k,ans,mark[9]; 4 char map[9][9]; 5 void DFS(int k,int r) 6 { 7 if(k==0) 8 { 9 ... Read More
posted @ 2013-07-13 22:47 瓶哥 Views(396) Comments(0) Diggs(0) Edit
DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the game is to lead the stone from the s Read More
posted @ 2013-07-13 20:45 瓶哥 Views(310) Comments(0) Diggs(0) Edit
1.任何改变vector长度的操作都会使已经存在的迭代器失效vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。 为了可以使用vector,必须在你的头文件中包含下面的代码: #include vector属于std命名域的,因此需要通过命名限定,如下完成你的代码: using std::vector; vector vInts; 或者连在一起,使用全名: std::vec... Read More
posted @ 2013-07-13 16:50 瓶哥 Views(323) Comments(0) Diggs(0) Edit
得到的并非最优解 1 /* 2 迭代加深搜索解埃及分数 3 19/45=1/3 + 1/12 + 1/180 4 19/45=1/3 + 1/15 + 1/45 5 19/45=1/3 + 1/18 + 1/30 6 19/45=1/4 + 1/6 + 1/180 7 19/45=1/5 + 1/6 + 1/18 8 最后一种最好,因为1/18比1/180,1/45,1/30,1/180都大 9 */10 //按照分母递增的顺序来扩展,若扩展到d层时,11 //前d个分数之和为 now ,而第d个分数为 1 / maxdion,则接下来12 //至少还要( frac - now )... Read More
posted @ 2013-07-13 15:22 瓶哥 Views(346) Comments(0) Diggs(0) Edit
DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their quest to find the exit. One popular maze-walking strategy guarantees that the visitor will . Read More
posted @ 2013-07-13 12:15 瓶哥 Views(254) Comments(0) Diggs(0) Edit