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.
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 . That's why we won't simulate Mirko's process, but count the number of letters A
and B
in the following way:
- initially, and
- in one step we get one letter
A
for each letterB
we've had so far, and one letterB
for each letterA
and each letterB
we've had so far; therefore: and
Comments