PDP-17 (2005) - Phase C' - 1 (digits)

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

Unique Multiplication

Consider the following multiplication example: 48 x 159 = 7,632. The interesting fact is that all nine digits are different, and there is no 0 involved.

Construct a program named digits.c or digits.pas depending on the programming language used.

Your program will take as input a file named digits.in. This file will contain an integer M, where 1 \le M \le 98,765,432.

Your program should output to a file named digits.out with 1 line, containing:

  • two integers M_1 and M_2, such that M x M_1 = M_2, and all digits of M, M_1, M_2 are different from each other (and without containing 0). There should be a single space between the two numbers M_1 and M_2.

or

  • the number 0, if there are no suitable M_1 and M_2 such that M x M_1 = M_2.
Input/Output File Examples:
1st

STDIN (digits.in)

48

STDOUT (digits.out)

159 7632
2nd

STDIN (digits.in)

51

STDOUT (digits.out)

0

Time Limit: 1 sec per testcase.

Clarification: Each line, both in the input and output files, ends with a newline character (for C and C++ programmers: "\n", while for Pascal programmers the use of ReadLn and WriteLn is sufficient).


Comments

There are no comments at the moment.