TASK: crypt1
LANG: C
Compiling...
Compile: OK
Executing...
Test 1: TEST OK [0.004 secs]
Test 2: TEST OK [0.004 secs]
Test 3: TEST OK [0 secs]
Test 4: TEST OK [0.004 secs]
Test 5: TEST OK [0.004 secs]
Test 6: TEST OK [0.004 secs]
Test 7: TEST OK [0.004 secs]
All tests OK.
YOUR PROGRAM ('crypt1') WORKED FIRST TIME! That's fantastic
-- and a rare thing. Please accept these special automated
congratulations.
Here are the test data inputs:
------- test 1 ------- 5 2 3 4 6 8 ------- test 2 ------- 4 2 3 5 7 ------- test 3 ------- 1 1 ------- test 4 ------- 7 4 1 2 5 6 7 3 ------- test 5 ------- 8 9 1 7 3 5 4 6 8 ------- test 6 ------- 6 1 2 3 5 7 9 ------- test 7 ------- 9 1 2 3 4 5 6 7 8 9 ----------------------Keep up the good work!
Thanks for your submission!
枚举100-999乘10-99,这个过程中分别判断产生的竖式中每一项是否符合要求即可。
附题如下:
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 the solution for the sample input:
2 2 2
x 2 2
------
4 4 4
4 4 4
---------
4 8 8 4
SAMPLE OUTPUT (file crypt1.out)
1
解决一道USACO竞赛中的Prime Cryptarithm题目,通过枚举和验证找到所有可能的解,使用指定的数字集{1,2,3,4,5,6,7,8,9}
1725

被折叠的 条评论
为什么被折叠?



