Editorial for WC '17 Finals J1 - Cownterintelligence
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.
Upon inputting each cow 's moo frequency
, we'll need to determine whether it's a power-of-
multiple of
, and output the number
if it's not.
One way to check this is to initialize a variable to be equal to
, and then repeatedly multiply
by
while checking if it's equal to
at each iteration. If we do find a value of
which is equal to
, then we know that cow
isn't an imposter, and we'll want to skip over it. On the other hand, if
never becomes equal to
and instead gets to be larger than
, then we know that cow
is an alien imposter.
Comments