欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1202A.You Are Given Two Binary Strings...
You Are Given Two Binary Strings...
You are given two binary strings and , which are binary representations of some two integers (let's denote these integers as and ). You can choose any integer , calculate the expression and write the binary representation of in reverse order (let's denote it as ). For example, let and ; you've chosen and, since , so and .
For given and , you need to choose such that is lexicographically minimal (read notes if you don't know what does "lexicographically" means).
It's guaranteed that, with given constraints, exists and is finite.
Input
The first line contains a single integer () — the number of queries.
Next lines contain a description of queries: two lines per query. The first line contains one binary string , consisting of no more than characters. Each character is either 0 or 1.
The second line contains one binary string , consisting of no more than characters. Each character is either 0 or 1.
It's guaranteed, that (where is the integer represented by , and is the integer represented by ), both representations don't have any leading zeroes, the total length of over all queries doesn't exceed , and the total length of over all queries doesn't exceed .
Output
Print integers (one per query). For each query print such that is lexicographically minimal.
Note
The first query was described in the legend.
In the second query, it's optimal to choose . The so $s_3 = 10001_2 + 110_2 \cdot 1000_2 = 10001 + 110000 = 1000001$ and . For example, if , then and , but is lexicographically smaller than .
In the third query and . For example, and . And is lexicographically smaller than .
The quote from Wikipedia: "To determine which of two strings of characters comes when arranging in lexicographical order, their first letters are compared. If they differ, then the string whose first letter comes earlier in the alphabet comes before the other string. If the first letters are the same, then the second letters are compared, and so on. If a position is reached where one string has no more letters to compare while the other does, then the first (shorter) string is deemed to come first in alphabetical order."
Samples
4
1010
11
10001
110
1
1
1010101010101
11110000
1
3
0
0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |