Mystery Square (Small)
Time limit5sMemory limit512 MB
Fill each ? in the binary string with 0 or 1 so the result is a perfect square.
- Level
Easy3 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
I wrote down a large perfect square in binary, then replaced some of its digits with question marks. Work out what my original number was.
Input
The first line of the input gives the number of test cases, . The next lines each contain one test case: a string , a perfect square written in binary with some of its digits replaced by question marks.
Output
For each test case, print one line in the form Case #x: N, where x is the test case number starting from 1 and N is a perfect square written in binary, obtained by replacing each '?' in with either '0' or '1'.
Constraints
- begins with '1'.
- contains only the characters '0', '1' and '?'.
- In every test case there is exactly one possible choice for N.
- is at most 60 characters long.
- contains at most 20 '?' characters.