home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume17
/
contest-prog
/
part02
/
prob14.txt
< prev
next >
Wrap
Text File
|
1989-02-06
|
1KB
|
30 lines
Problem 14: Reverse products.
The product 64 * 69 = 4416, and so also is the product 46 * 96 with the
digits reversed in both numbers. Write a program that prints all such
pairs of two-digit numbers with this property. For purposes of this
problem, numbers less than 10 are to be considered two-digit numbers.
However, exclude the following: numbers having the same two digits
(e.g., 77), pairs where one of the original numbers is just the
reverse of the other (e.g., 46 and 64), and any DUPLICATE sets of
numbers (i.e., the foursome 46, 64, 69, 96 should be found just once).
The output for this problem should consist of lines,
each with two values: p = the smallest element of a foursome, and
q = the corresponding product value. Thus, the line for this example
case would contain: 46 4416. Moreover, the lines should be
ordered by values of p, and then by values of q in case of
repetitions of p values.
There is no input file for this problem.
Sample output:
1 20 <this is tricky: comes from 01*20 == 10*02 >
1 30
...
...
34 2924
...
Hint: there are fifty output lines in a correct answer.