Editorial for COCI '13 Contest 3 #1 Riječi


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

If we tried to simulate what Mirko is doing, we would have exceeded both the time and memory limit because the words that Mirko reads out on the screen can consist of hundreds of thousands (or even millions) of characters, even for small K. That's why we won't simulate Mirko's process, but count the number of letters A and B in the following way:

  • initially, \text{number_of_A} = 1 and \text{number_of_B} = 0
  • in one step we get one letter A for each letter B we've had so far, and one letter B for each letter A and each letter B we've had so far; therefore: \text{new_A} = \text{number_of_B} and \text{new_B} = \text{number_of_A} + \text{number_of_B}

Comments

There are no comments at the moment.