UVa 524 Prime Ring Problem:数论&DFS

524 - Prime Ring Problem

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=465

A ring is composed of n (even number) circles as shown in diagram. Put natural numbers 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 <= 16)

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.

You are to write a program that completes above process.

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

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索numbers
, prime
, number
, 数论
, flash problem
, problem
should
uva524、prime ring problem、sheringham prime、prime、亚马逊prime,以便于您获取更多的相关知识。

时间: 2024-11-05 18:39:24

UVa 524 Prime Ring Problem:数论&amp;DFS的相关文章

HDU1016-Prime Ring Problem

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26682    Accepted Submission(s): 11908 Problem Description A ring is compose of n circles as shown in diagram. Put natural num

UVa 10780 Again Prime? No Time.(数论&amp;amp;素因子分解)

10780 - Again Prime? No Time. Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&category=467&page=show_problem&problem=17 21 The problem statement is very easy. Given a number n you have to det

UVa 639 Don&#039;t Get Rooked:DFS好题

639 - Don't Get Rooked Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=580 In chess, the rook is a piece that can move any number of squares vertically o

UVa 10924 Prime Words:素数

10924 - Prime Words Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1865 A prime number is a number that has only two divisors: itself and the number one.

UVa 10791 Minimum Sum LCM (数论&amp;amp;素因子分解)

10791 - Minimum Sum LCM Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&category=467&page=show_problem&problem=17 32 LCM (Least Common Multiple) of a set of integers is defined as the minimum

UVa 101 The Blocks Problem 数据结构专题

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=37 题目类型: 数据结构, 二叉树 题意: 有N个位置, 编号为 0-N-1, 初始下,各个位置上放置这和位置编号相同的砖块,即砖块1,砖块2--砖块N-1. 然后有四种命令操作方式: 1.move a onto b :把砖a移动到砖b上面,如果a

UVa 105 The Skyline Problem (想法题)

105 - The Skyline Problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=41 这题有个很巧的思路:离散化. 什么意思呢?既然每栋大楼的高和左右边界都是整数,那么不妨把线段用一个个整点表示.既然最后只求一个轮廓,那么对每个横坐标,就记

UVa 10110 Light, more light:数论

10110 - Light, more light Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=1051 The Problem There is man named "mabu" for switching on-off light

UVa 101 The Blocks Problem (超级模拟)

101 - The Blocks Problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=37 Background Many areas of Computer Science use simple, abstract domains for bot