HDU 1016 Prime Ring Problem - 隐式图的搜索
2014-08-10 16:03
190 查看
《BestCoder用户手册》下载 |
Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26774 Accepted Submission(s): 11943 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). Output The output format is shown as sample below. Each row represents a series of circle numbers in the ring beginning from 1 clockwisely and anticlockwisely. The order of numbers must satisfy the above requirements. Print solutions in lexicographical order. You are to write a program that completes above process. Print a blank line after each case. Sample Input 6 8 Sample Output Case 1: 1 4 3 2 5 6 1 6 5 2 3 4 Case 2: 1 2 3 8 5 6 7 4 1 2 5 8 3 4 7 6 1 4 7 6 5 8 3 2 1 6 7 4 3 8 5 2此题是利用dfs 的回溯现象排序,隐式图的搜索 |
相关文章推荐
- hdu 5012 Dice(隐式图搜索)
- HDU 1495 非常可乐【隐式图搜索,BFS】
- HDU 1495 非常可乐(隐式图搜索)
- HDU 1495 非常可乐!!!(隐式图状态搜索+bfs+map状态查重)
- HDU 5012 Dice 隐式图的搜索
- HDU 2241(搜索题,三分)
- HDU 2446(搜索题,二分)
- HDU 1969(搜索题,二分)
- HDU 1251(搜索题,典型的字典树问题)
- hdu 1015 Safecracker 暴力搜索
- HDU 2899(搜索题,二分)
- hdu 1242 Rescue BFS搜索
- HDU 1399(搜索题,暴力- -!)
- HDU 1551(搜索题,二分)
- HDU 1016(搜索题,DFS)
- HDU 1241(搜索题,DFS)
- HDU 2289(搜索题,二分、几何)
- HDU 3400(搜索题,三分~~初识三分查找)
- HDU 2199(搜索题,二分)
- HDU 2612(搜索题,BFS)