10115_PrimeCryptari

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

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

Pro.ID

10115

Title

Prime Cryptarithm

Title链接

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

AC

78

Submit

149

Ratio

52.35%

时间&空间限制

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

    The following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the set of prime digits {2,3,5,7} is selected, the cryptarithm is called a PRIME CRYPTARITHM.

             * * *
          x    * *
           -------
             * * *        <-- partial product 1
           * * *          <-- partial product 2
           -------
           * * * *

    Digits can appear only in places marked by '*'. Of course, leading zeroes are not allowed.

    Note that the 'partial products' are as taught in USA schools. The first partial product is the product of the final digit of the second number and the top number. The second partial product is the product of the first digit of the second number and the top number.

    Write a program that will find all solutions to the cryptarithm above for any subset of digits from the set {1,2,3,4,5,6,7,8,9}.

    输入

    Multiple test cases. The first line of the input file is an integer T , indecating the nunber of test case.

    For each test case:

    Line 1:      N, the number of digits that will be used

    Line 2:      N space separated digits with which to solve the cryptarithm

    输出

    Description

    The following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the set of prime digits {2,3,5,7} is selected, the cryptarithm is called a PRIME CRYPTARITHM.

             * * *
          x    * *
           -------
             * * *        <-- partial product 1
           * * *          <-- partial product 2
           -------
           * * * *

    Digits can appear only in places marked by '*'. Of course, leading zeroes are not allowed.

    Note that the 'partial products' are as taught in USA schools. The first partial product is the product of the final digit of the second number and the top number. The second partial product is the product of the first digit of the second number and the top number.

    Write a program that will find all solutions to the cryptarithm above for any subset of digits from the set {1,2,3,4,5,6,7,8,9}.

    Input

    Multiple test cases. The first line of the input file is an integer T , indecating the nunber of test case.

    For each test case:

    Line 1:      N, the number of digits that will be used

    Line 2:      N space separated digits with which to solve the cryptarithm

    Output

    A single line with the total number of unique solutions. Here is the single solution for the sample input:

         2 2 2
       x   2 2
        ------
         4 4 4
       4 4 4
     ---------
       4 8 8 4

    Sample Input

    1
    5
    2 3 4 6 8

    Sample Output

    1

    Source

    样例输入

    1
    5
    2 3 4 6 8

    样例输出

    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部