Home STD Contest Notification Clarification Problems Ranklist Status Print Sign Out
比赛题目已经加到题库最后,欢迎继续AC~More...

The Three Groups

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 531    Accepted Submission(s): 188


Problem Description
There appeared in “Nouvelles Annales de Mathematiques” the following puzzle as a modification of any of my “Canterbury Puzzles.” Arrange the nine digits in three groups of two, three, and four digits, so that the first two numbers when multiplied together make the third. Thus, 12 * 483 = 5,796. I now also propose to include the cases where there are one, four and four digits, such as 4 * 1,738 = 6,952. Can you find all possible solutions in both cases?”- Amusement in Mathematics, by Ernest Dudeney.

Now we want to arrange some of the nine digits (without ‘0’) in three groups of a, b and c digits, so that the first two numbers when multiplied together make the third. In addition, no digit can be used more than once in a single multiplication. You have to find how many solution exist there for given a, b and c.
 

Input
There are multiple test cases. In addition, each test case is consisting of three integers a, b, c separated by spaces.(a , b , c >= 0 && a + b + c <= 9) Meaning of a, b, and c are described in the problem statement. The last case contains exactly three 0’s for all of a, b, c and indicates the end of input stream. This line should not be processed.
 

Output
Your program should print a single integer for each input in a single line. The integer will state that how many solution there are for the given size of a, b and c.
 

Sample Input
2 3 4 1 1 1 0 0 0
 

Sample Output
7 4 Note: The valid solutions for the second sample input-output are as following: 2*3 =6 2*4 =8 3*2 =6 4*2 =8
 

Author
Muhammed Hedayet
 

Statistic | Submit | Clarifications | Back