P13381 [GCJ 2011 #3] Mystery Square
Description
I have written down a large perfect square in binary, and then replaced some of the digits with question marks. Can you figure out what my original number was?
Input Format
The first line of the input gives the number of test cases, $T$. $T$ test cases follow, one per line. Each line contains $S$: a perfect square written in binary, but with some of the digits replaced by question marks.
Output Format
For each test case, output one line containing "Case #$x$: $N$", where $x$ is the case number (starting from 1) and $N$ is a perfect square written in binary, obtained by replacing each '?' character in $S$ with either a '0' character or a '1' character.
Explanation/Hint
**Limits**
- $1 \leq T \leq 25$.
- $S$ begins with '1'.
- $S$ contains only the characters '0', '1', and '?'.
- In every test case, there is exactly one possible choice for $N$.
**Small dataset (10 Pts, Test set 1 - Visible)**
- $S$ is at most $60$ characters long.
- $S$ contains at most $20$ '?' characters.
- Time limit: ~~30~~ 6 seconds.
**Large dataset (31 Pts, Test set 2 - Hidden)**
- $S$ is at most $125$ characters long.
- $S$ contains at most $40$ '?' characters.
- Time limit: ~~60~~ 20 seconds.