Problem G
Over the Hill, Part 2
Bob Roberts is part of a crack espionage team working for
the CIA (Chocolate Institute of Alabama) and he is working on
decrypting the encoded messages of their arch rivals at the NSA
(Nougat Society of Arkansas). Fortunately, the NSA’s espionage
staff is not nearly as crack as Bob’s as they are using the
Hill encryption scheme (described in the previous problem)
which is susceptible to a known-plaintext attack. Bob has
intercepted a plaintext/ciphertext pair and has knowledge of
the size of the encryption matrix used by his not-so-sweet
enemies. Given these Bob knows that there is a way to determine
the encryption matrix, but no one on his staff is exactly sure
how (hmmm
Input
Input begins with a line containing a positive integer
Output
Output one of three possible answers. If the input does not admit any possible encryption matrix output No solution. Otherwise if the input does not uniquely determine the encryption matrix output Too many solutions. Otherwise output the encryption matrix, one row per line with a single space between values on a line.
Sample Input 1 | Sample Output 1 |
---|---|
3 ATTACK AT DAWN FPLSFA4SUK2W9K3 |
30 1 9 4 23 7 5 9 13 |
Sample Input 2 | Sample Output 2 |
---|---|
3 ATTACK FPLSFA |
Too many solutions |
Sample Input 3 | Sample Output 3 |
---|---|
3 ATTACK AT DAWN EPLSFA4SUK2W9K3 |
No solution |