10187_ThePrimes

2022-5-16 18:16| 发布者: Hocassian| 查看: 68| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504643797400-Problem List-采集的数据-后羿采集器.html

Pro.ID

10187

Title

The Primes

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10187

AC

3

Submit

14

Ratio

21.43%

时间&空间限制

  • Time Limit: 600/300 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    In the square below, 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.

    +---+---+---+---+---+
    | 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 |
    +---+---+---+---+---+

    • The prime numbers' digits must sum to the same number.

    • 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 (sorted in numerical order as if the 25 digits were all one long number).

    输入

    A single line with two space-separated integers: the sum of the digits and the digit in the upper left hand corner of the square.

    输出

    Description

    In the square below, 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.

    +---+---+---+---+---+
    | 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 |
    +---+---+---+---+---+

    • The prime numbers' digits must sum to the same number.

    • 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 (sorted in numerical order as if the 25 digits were all one long number).

    Input

    A single line with two space-separated integers: the sum of the digits and the digit in the upper left hand corner of the square.

    Output

    Five lines of five characters each for each solution found, where each line in turn consists of a five digit prime number. Print a blank line between solutions. If there are no prime squares for the input data, output a single line containing "NONE".

    Sample Input

    11 1

    Sample Output

    The above example has 3 solutions.

    11351
    14033
    30323
    53201
    13313

    11351
    33203
    30323
    14033
    33311

    13313
    13043
    32303
    50231
    13331

    Source

    样例输入

    11 1

    样例输出

    The above example has 3 solutions.

    11351
    14033
    30323
    53201
    13313

    11351
    33203
    30323
    14033
    33311

    13313
    13043
    32303
    50231
    13331

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部