USACO Prime Cryptarithm Accepted

传说这道题容易超时,结果一遍就过了,意外^_^。

USACO Training Grader Results for DaN marner [danmarn1]

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,这个过程中分别判断产生的竖式中每一项是否符合要求即可。

附题如下:


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

 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值