Pro.ID10115 TitlePrime Cryptarithm Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10115 AC78 Submit149 Ratio52.35% 时间&空间限制描述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. * * * 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. * * * 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 Sample Input 1 Sample Output 1 Source 样例输入1 样例输出1 作者 |