编程介的小学生 2017-02-11 12:55 采纳率: 20.5%
浏览 868
已采纳

The Primes

问题描述 :

|---|---|---|---|---|

| 1 | 1 | 3 | 5 | 1 |

|---|---|---|---|---|

| 3 | 3 | 2 | 0 | 3 |

|---|---|---|---|---|

| 3 | 0 | 3 | 2 | 3 |

|---|---|---|---|---|

| 1 | 4 | 0 | 3 | 3 |

|---|---|---|---|---|

| 3 | 3 | 3 | 1 | 1 |

|---|---|---|---|---|

(Figure 1)

Figure 1 shows a square. Each row, each column and the two diagonals can be read as a five digit prime number. The rows are read from left to right. The columns are read from top to bottom. Both diagonals are read from left to right. Write a program that constructs such squares:

The prime numbers must have the same digit sum (11 in the example).


The digit in the top left-hand corner of the square is pre-determined (1 in the example).


A prime number may be used more than once in the same square.


If there are several solutions, all must be presented.


A five digit prime number cannot begin with zeros, ie 00003 is NOT a five digit prime number. 

输入:

Your program is to read from standard input. First the digit sum of prime numbers and then the digit in the top left-hand corner of the square. The file contains two lines. There will always be a solution to the given test data.
输出:

Your program is to write to standard output. Output five lines for each solution found, where each line in turn consists of a five digit prime number. The solutions are sorted by the prime in the first row, then by the prime in the second row,etc. Output a blank line after each solution.
样例输入:

11
1
样例输出:

11351
14033
30323
53201
13313

11351
33203
30323
14033
33311

13313
13043
32303
50231
13331

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-15 14:58
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题