Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help in understanding a particular program  RSS feed

 
Ranajoy Saha
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Everyone

I was going through some old question papers of Indian National Olympiad in Informatics and came accross this PDF. In Page Number 5 of this PDF, there's this question about periodic strings.
That for example if "110110" is to be considered a string then it is a periodic string which can be represented as "110"^2. And there's this line saying "Report the answer modulo M". This is where I am confused. I get the question and what it is wanting (some what) but I am still confused about how I should start off. I don't know, maybe the logic isn't clear for me. So, if anyone would help me, like provide me with some more examples and explain to me what the question is asking, it would be very kind of you.


Regards,
Ranajoy Saha
 
Stephan van Hulst
Saloon Keeper
Posts: 7808
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems unrelated to me. I don't think the modulo matters, unless there's a way to calculate the result quickly if you know something about the relationship between the number of non-periodic strings and M.

At any rate, you can start out by calculating the number of non-periodic strings, and then just print result % M.
 
Campbell Ritchie
Marshal
Posts: 55715
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the complete question (not the PDF please).

Start by working out the problem with pencil and paper, not a computer.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!