搜索
文章平均质量分 59
Prime me
Nobody can defeat me unless I don't want to win.
展开
-
N皇后问题(暴力DFS&&回溯DFS)
在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。 方法一:暴力递归法; 暴力递归法即为将所有方案全部计算出,当一种方案计算出结果后,将此时的vis数组与s输出循环计算一遍,判断此种情况下是否可以满足题目要求的不在同一行,同一列以及是否在期盼的45°斜边上。若是满足条件则加一,不然则退出。 #include<iostream> using namespac.原创 2021-12-07 16:34:12 · 373 阅读 · 0 评论 -
J - Nightmare Ⅱ(DBFS)
Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were trapped in a big maze separately. More terribly, there are two ghosts in the maze. They will kill the people. Now little erriyue wants to know if he could fin.原创 2021-07-28 21:17:02 · 59 阅读 · 0 评论