寒假翻译题训练 2月8号

此编程任务涉及创建一个环形排列,其中相邻数字之和为质数。输入为圆环的圈数n,输出所有可能的解决方案,从1开始,按字典序排列。示例输入为n=6,输出应展示所有符合条件的数字环。解题需要理解质数和环形排列的算法实现。
摘要由CSDN通过智能技术生成

链接:https://acs.jxnu.edu.cn/problem/HDU1016

题目:

描述:

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.

输入:

n (0 < n < 20).

输出:

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.

翻译如下

描述:

有一个图形是由n个圆串起来的环组成的。将自然数1,2,...,n分别放入每一个圆里,并且相邻的两个圆里面的数字的合必须是质数。

注意,第一个圆里的数字必须为1。

输入:

n (0 < n < 20).

输出:

输出格式如下。每一行表示存在的解法,每个解法必须由1开头,并且顺序对应逆时针排序的图。(图中的解法表示为1 4 3 2 5 6).数字的排序必须满足以上的要求。请按字典序输出所有的解法。你需要编写一个程序来完成以上任务。
每两个样例之间需要有一个空行将其隔开。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值