Prime Cryptarithm

来源:百度知道 编辑:UC知道 时间:2024/09/28 11:30:55
Prime Cryptarithm

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

Digits can appear only in places marked by `*'. Of course, leading zeroes are not allowed.
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}.

PROGRAM NAME: crypt1
INPUT FORMAT
Line 1: N, the number of digits that will be used
Line 2: N space separated digits with which to solve the cryptarithm

SAMPLE INPUT (file crypt1.in)
5
2 3 4 6 8

OUTPUT FORMAT
A single line with the total number of unique solutions. Here is th

精华 Cryptarithm

下列的 cryptarithm 是能是的一个乘法问题解决藉由替换数字从一指定的组 N 数字进入位置之内显着的与 *. 如果那组精华数字 {2,3,5,7} 是挑选的, cryptarithm 是呼叫一精华 CRYPTARITHM。

***
x**
-------
***
***
-------
****

数字才能在地方中出现显着的被*'. 当然, 带领零是不允许。
写一计画意志找所有的对 cryptarithm 的解决办法上方为任何的数字的子集从那组 {1,2,3,4,5,6,7,8,9}.

计画名字: 土窖 1
输入格式
第 1 行: N, 数字的数字哪一意志被用
第 2 行: N 空间分开了数字与哪一个解决 cryptarithm

样品输入 (文件土窖 1.在)
5
23468

输出格式
用独特解决的总数的一条线。 这里是那独身者解决为样品输入:

222
x 22
------
444
444
---------
4884

样品输出 (文件土窖 1.外面的)
1