|
|||||||||||||||||||
|
SPOJ time: 2010-09-02 19:52:54 |
Car Plate GenerationProblem code: HS09CPG
Little John has become obsessed with car plates. He spends entire hours just watching the cars pass by and writing down the plates in his notebook. After many days trying to find a common pattern for the plates, Little John can't believe what his eyes see. It seems that the plates are generated in such a way that:
For example, let us look at one of the plates Little John wrote down: HAA001 If we make the following matching: 'H'->'1' And then divide the plate by its half: HAA|001 Then the plate, according to the matching, appears to be 'mirrored': P[0] = 'H' P[5] = '1' Plates consist of L*2 characters, with the first L being capital letters of the english alphabet and the last L being decimal digits. You are to write a program that finds the i-th plate in the zero-based lexicographically sorted sequence of plates which can be made using the first S letters of the english alphabet plus the decimal digits and having length equal to L*2. InputInput starts with three space separated integers: the size of the alphabet (1<=S<=26), half the length of the plates (1<=L<=100) and the number of queries (1<=Q<=300). Q lines follow, each one having a single integer (0<=I<=10^115), the position of the desired plate in the described sequence. OutputOutput the Q desired plates, each one on a single line. ExampleInput: ScoringFor solving this problem you will score 10 points.
|
||||||||||||||||||
| |||||||||||||||||||