当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4733:G(x)

题目描述
For a binary number x with n digits (AnAn-1An-2 ... A2A1), we encode it as
Where "" is bitwise XOR operation and "" indicates the largest integer which is not greater than x.
Due to some reasons, Mzry1992 encode his password P into G(P), and additionally, he encode P + 1 into G(P + 1) too, and write G(P) and G(P + 1) into his diary.
This story happened many years ago and now you hold the diary with these numbers in your hands. Unfortunately, some digits are unreadable now. Could you determine the values of these digits using the readable digits?
输入解释
The first line has a number T (T <= 100) , indicating the number of test cases.
For every test case, it has 2 lines of same number of digits describe G(P) and G(P + 1), In every line, it only contains 1, 0 and ?. Unreadable digits are denoted with symbol ?, The length of every line in the input is up to 105.
输出解释
For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1.
Then, if there is impossible to restore G(P) and G(P + 1), you should output "Impossible" in the second line.
Otherwise, if G(P) is unique, you should output restored G(P) and G(P +1) in the same format.
Otherwise, you should output "Ambiguous" and the number of possible G(P) in the second line.
The number may be very large so the answer should modulo 10^9 + 7.
输入样例
3
10??
10??
0010
0110
1?01
0?01
输出样例
Case #1:
Ambiguous 3
Case #2:
0010
0110
Case #3:
Impossible
提示
In the first sample case, the three possible situations are:
1. 
G(12) = 1010
G(13) = 1011
2.  
G(13) = 1011
G(14) = 1001
3.  
G(14) = 1001
G(15) = 1000
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4733

最后修改于 2020-10-25T23:16:17+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/500MS(Java/Others) 32768/32768K(Java/Others)