编程介的小学生 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 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划