spoj#CRYPTO7. Cryptography Reloaded (Act II)

Cryptography Reloaded (Act II)

Please click here to download a PDF version of the contest problems. The problem is problem D in the PDF.