Time Limit: Java: 1000 ms / Others: 1000 ms
Memory Limit: Java: 32768 KB / Others: 32768 KB
A Svetlozar Sequence consists of positive int values greater than 9, written in decimal, where for any two consecutive terms, a and b, of the sequence, b is the smallest number which can be formed from a sequence of decimal digits which multiplied together equal a, i.e.,
For example, the first Svetlozar Sequence is 10, 25, 55. It starts with 10 which has the factors 1, 2, 5, and 10. Candidates for the next term include 25, 52, and 125; the smallest candidate is 25. The term 25 has factors 1, 5, and 25, and candidates for the next term include 55 and 155. For this sequence no more terms are possible after 55.
Write a program to compute a Svetlozar Sequence from the first value of the sequence, if possible.
The first input line contains one positive integer n. Each of the next n input lines contains one positive integer which is proposed as a starting value for a Svetlozar Sequence.
For each proposed starting value the output should be one line containing the first 10 terms of the Svetlozar Sequence (or fewer terms if the sequence is shorter). If the value cannot start a Svetlozar Sequence the output should be No sequence.