| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 14997 | More Popcornnnnn |
|
| 15000 | Wizard Tom with Hungry Tom |
|
Description
"I have something I'd like to say - Lizard. Lizard. Lizard."
Tom is a lizard who has a massive crush on popcorn. Even though a single piece of popcorn is almost as big as his mouth, he still enjoys it immensely.
As Tom's loyal fan, you decide to give him a huge bucket of popcorn! But before doing so, you must tell Tom exactly how many pieces of popcorn you are giving him, as counting is simply too difficult for a lizard. Being smart, you have already figured out that there are exactly pieces of popcorn in the bucket.
However, in the lizard world, they do not use the decimal system, nor do they use Arabic numerals. Instead, these are decided based on their mood for the day. Specifically, Tom will give you a positive integer , representing the base of the numeral system he wants to use today.
Then, he will give you a string of length , representing the symbols Tom uses to express numbers. Specifically, (the -th character of string , 0-indexed) corresponds to the digit value in this base- system.
For example, if and "AB", it means Tom wants to use the binary (base-2) system today. The traditional 0 is replaced by 'A', and the traditional 1 is replaced by 'B'. Therefore, the decimal number 13 (which is 1101 in binary) must be represented as B B A B in Tom's eyes.
Given the string provided by Tom, please convert into base and output the result. Each digit should be separated by a space.
Update: If you keep getting Presentation Error, it might be a problem with blank spaces at the end of lines.
Tip: You may use " S = S[::-1] " to reverse a string S, for example
> S = "abc"
> S = S[::-1]
> print(S) # You'll get "cba"
Input
The input is given from Standard Input in the following format:
- Guarantee that is composed of unique ASCII characters
Output
Using , output in -based system, with a space between every two digits.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The content after the last separation line is newly added by Lab
One day, Lizard Tom ran into his idol, Wizard Tom! Just thinking about Wizard Tom making endless popcorn made Lizard Tom drool.
"I have an integer in my mind, ranging from to . If you can guess it, I'll magically make some popcorn for you!" Wizard Tom said with a grin. Although it sounded like a boring and childish game, Lizard Tom decided to play along just for the popcorn.
"I guess 1!", "I guess 2!", "I guess 3!"... The "smart" Lizard Tom had just learned how to count, and it was obvious that he intended to guess every single number from to sequentially.
If Lizard Tom keeps playing like this, the sun will set before he gets his treats. You decide to help Tom come up with a more reasonable strategy:
- Calculate a number , where . represents the greatest integer less than or equal to
- Tell Tom to guess for this round.
- If m = t, it means Tom has successfully guessed the number, and the guessing ends, skip the remaining steps; Moreover, if Tom has finished guesses without finding , the guessing also ends.
- Check if holds true: if it is true, update to ; otherwise, update to .
- If still holds, take the updated and and go back to Step 1.
Lizard! Lizard! Lizard!
Looking at Tom, who is now distracted and playing with buttons, you realize he hasn't even learned how to add and subtract. Therefore, please write a program to execute this strategy and decide what number Tom should guess:
For each round Tom makes a guess , output Guess m and a newline. If Tom successfully finds and the search ends, after outputting the final Guess t, output an additional line Take y times to find t, where is the total number of guesses Tom made, and terminate the search.
Nevertheless, Tom is so hungry after playing with his buttons that he can only afford to make a maximum of guesses. If Tom fails to find within attempts (less than or equal to ), he will simply give up. In this case, after outputting his final Guess m, output an additional line Hungryyy and terminate the program immediately.
Input
The input is given from Standard Input in the following format:
- For 50% of the testcases,
Output
For each round Tom makes a guess , output Guess m and a newline. If Tom successfully finds and the search ends, after outputting the final Guess t, output an additional line Take y times to find t, where is the total number of guesses Tom made.
If Tom fails to find within attempts (less than or equal to ), he will simply give up. In this case, after outputting his final Guess m, output an additional line Hungryyy and terminate the program immediately.