Given a list of words you are allowed to rotate each word exactly K times. Here rotations mean rotate left to right by shifting each character towards right in a cyclic manner. Find the number of words which remain unchanged after exactly K such operations.
Second Question
World War II involved the usage of a lot of ships. In order to win you had to align the ships in a specific order. The order is -> 1. There are several layers of ships 2. Each ship has a value (v) associated with it. 3. Each ship is followed by (v*v + 1)%M distinct ships in the next layer having values from 0 to [(v*v + 1)%M] - 1 4. In the first layer there is only one ship with value (v) =2. Find the total no of ships in all the layers modulo M.