Submit | All submissions | Best solutions | Back to list |
PLNPAIR - Palindrome Pair |
A palindrome is a sequence of alphanumeric characters, that can be read forward and backward just the same. For this problem, we'll only care about palindromes that consist only of digits [0, 9]. Given the previous definition, the number 121 is a palindrome, while 1234 is not.
You'll be given a list of N not necessarily distinct positive integers A1, A2 ... AN, where (3 <= N <= 15) and (1 <= Ai <= 999). You are required to find all pairs (Ai, Aj) where i is less than j, such that the product of Ai and Aj is a palindrome.
Input
The input has more than one data set, each on a sperate line, and will be terminated by EOF. Each set will contain an undefined number of space separated integers satisfying the constraints stated above. Input is very large, so you might be careful with I/O.
Output
For every set given in the input print all pairs required in the statement on the form "X Y Z", where X is element Ai, Y is element Aj, and Z is the result of their product, each on its own line.
You should assume that there'd be such a pair in each set. Pairs should be printed sorted according to their presence in the input. Also print "---" after every set.
Example
Input: 1 2 3 3 2 1 11 11 10 Output: 1 2 2 1 3 3 2 3 6 --- 3 2 6 3 1 3 2 1 2 --- 11 11 121 ---
Added by: | Mahmoud Aladdin |
Date: | 2013-02-28 |
Time limit: | 0.5s-1.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP JAVA |
Resource: | Own creation |