Editorial for MWC '15 #1 P5: Love Guru


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.

First of all, we should note that \bmod 10 is just taking the unit digit (with the special case described for 0). The unit digits of the powers of a number follows a pattern. Additionally, only the unit digit of the base of the power is relevant, meaning 26^N \bmod 10 is equivalent to 6^N \bmod 10. Either storing the number cycles or modding the power by 4 (the LCM of the cycle lengths of the digits) is sufficient to pass.

Time complexity: \mathcal{O}(L_T) where L_T is the total number of letters in both names.


Comments

There are no comments at the moment.