I recently joined TopCoder and practiced in Practice Rooms for the past few days. I ran into this problem which I seem to be unable to solve. Any help would be appreciated.
Problem
The product value for a string is the product of all the digits ('0' - '9') in String. For example, a product value of "123" is 1 * 2 * 3 = 6. A line is called colored if it contains only numbers and the product value of each of its non-empty adjacent substrings is different.
For example, the string "263" has six substrings: "2", "6", "3", "26", "63", and "263". The product values of these Substrings are: 2, 6, 3, 2 * 6 = 12, 6 * 3 = 18, and 2 * 6 * 3 = 36, respectively. Because all six value products are different, "263" is colorful.
On the other hand, "236" is not colorful, because its two substrings "6" and "23" have the same product value (6 = 2 * 3).
Returns the kth (1-based) lexicographically smallest colorful string of length n. If there are less than k colored strings of length n, return an empty string instead.
My approach
"0" "1" n.
. , n 9. ( 2, 3, 4, 5, 6, 7, 8, 9, ).
, "23" ( 2- ) (, - , ) n.
n, "" , k- .
, . , , k-- ?
? ?
, . - .
, , , . , , , - , , - .
=)
* , SRM 464 DIV 2 - 500pt. . TopCoder.