Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 945147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:42:25+00:00 2026-05-15T22:42:25+00:00

I’ve recently joined TopCoder and have been practicing in the Practice Rooms for the

  • 0

I’ve recently joined TopCoder and have been practicing in the Practice Rooms for the last few days. I came across this problem which I cant seem to solve. Any help will be appreciated.

The problem

The product value of a string is the
product of all the digits (‘0’-‘9’) in
the string. For example, the product
value of “123” is 1 * 2 * 3 = 6. A
string is called colorful if it
contains only digits and the product
value of each of its nonempty
contiguous substrings is distinct.

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. Since all six product
values are distinct, “263” is
colorful.

On the other hand, “236” is not
colorful because two of its
substrings, “6” and “23”, have the
same product value (6 = 2 * 3).

Return the k-th (1-based)
lexicographically smallest colorful
string of length n. If there are less
than k colorful strings of length n,
return an empty string instead.

My approach

We can’t have ‘0’ and ‘1’ as digits in n.
All digits must be distinct. So to begin with, n should be smaller than 9. (only the digits 2, 3, 4, 5, 6, 7, 8, 9 can be used, each of them only once).

Since we know that, we can start with “23” (the smallest 2-digit colorful string) as the base string and add one of the allowed digits (check if the string is still colorful or not, on each addition) until we reach length n.

Once we reach length n, we can “play around” with the digits to find the k-smallest.

My question

I feel like this approach will not be fast enough. Even if it is, in what systematic way should I play around with the digits, so that I start from the smallest and make my way through the kth-smallest?

How can I make progress on this problem with this approach? Or are there smarter ways to follow in these kind of problems?

I’m not asking for any solutions or anything. I’m just asking for some clues and some lead.

Some problems I solve in seconds, some take hours of thinking and some like this I can’t do it. But I believe all it takes is some practice, but I cannot make progress without someone leading the way.

Thanks in advance =)

*by the way, this question is from SRM 464 DIV 2 – 500pt. problem. All copyright goes to TopCoder.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:42:26+00:00Added an answer on May 15, 2026 at 10:42 pm

    Topcoder has a forum in which they create a thread for each SRM (464 is here). Maybe your question is already answered there 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.