QOJ.ac

QOJ

Time Limit: 6 s - 12 s Memory Limit: 1024 MB Total points: 41

#5874. Mystery Square

الإحصائيات

Problem

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

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

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.

Limits

1 ≤ T ≤ 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.

Memory limit: 1GB.

Small dataset (Test set 1 - Visible; 10 Points)

S is at most 60 characters long.

S contains at most 20 '?' characters.

Time limit: 30 6 seconds.

Large dataset (Test set 2 - Hidden; 31 Points)

S is at most 125 characters long.

S contains at most 40 '?' characters.

Time limit: 60 12 seconds.

Sample

3
1???
1
10??110??00??1000??
Case #1: 1001
Case #2: 1
Case #3: 1011110110000100001
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.