杭电acm 1016
来源:互联网 发布:广联达软件百度云 编辑:程序博客网 时间:2024/06/05 12:38
Prime Ring Problem
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 29581 Accepted Submission(s): 13190
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.
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.
You are to write a program that completes above process.
Print a blank line after each case.
Sample Input
68
Sample Output
Case 1:1 4 3 2 5 61 6 5 2 3 4Case 2:1 2 3 8 5 6 7 41 2 5 8 3 4 7 61 4 7 6 5 8 3 21 6 7 4 3 8 5 2
题目意思:输入一个数n,在n个圆圈的圆环内填入1-n个数字,使每两个相邻的数字相加之和为素数,就是DFS
0 0
- 杭电 ACM 1016
- 杭电acm 1016
- 奋战杭电ACM(DAY11)1016
- 杭电acm 1016 素数环
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电acm 1010
- 杭电 acm 1045
- 杭电ACM-1010
- 杭电ACM 1172
- 杭电ACM 1174
- 杭电ACM 1175
- 杭电ACM 分类
- 杭电ACM分类
- 杭电acm 1000
- 杭电acm 1001
- 杭电acm 1002
- 杭电acm分类
- 最小生成树(Prim)
- Ubuntu14.04下Eclipse崩溃“crash: fatal error in soup_session_feature_detach”修复办法
- vs自动注释add-in插件编写(二)--CConnect
- Kruskal【MST】
- USACO section2.2 Runaround Numbers题解&代码
- 杭电acm 1016
- Leetcode:Gray Code
- HotSpot SA #3:FinalizerInfo
- 函数指针之探秘
- 黑马程序员--继承、抽象类、接口
- 实现C语言字符串操作的库函数
- NYOJ 题目982 Triangle Counting(数学,递推)
- A/B 题目
- 高职院校文学鉴赏教学中培养学生的主体性策略