Editorial for COCI '07 Contest 4 #1 Vauvau


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.

One solution is to simulate minute by minute, keeping track of what mood each of the dogs is in, and how long he's been that way. We can write in an array how many dogs were aggressive during each minute and easily look up the answer for each of the heroes.

The other solution is using modular arithmetic. For example, the first dog is aggressive in minute M if 0 \le (M-1) \bmod (A+B) \le A-1, where \bmod represents the remainder operator.


Comments

There are no comments at the moment.