CF2242E.Product of Closures
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let the closure of a positive integer x>0 be the following infinite binary string C(x):
- Write x in binary form without leading zeros;
- Concatenate the obtained string with itself infinitely many times and call the result C(x).
For example, C(1) = 11111..., C(4) = 10010010010010..., C(9) = 100110011001....
Let the product of two closures C(x)&C(y) be the infinite binary string obtained by the bitwise binary AND of the strings C(x) and C(y). For example, for C(4)&C(9) we get
\\begin{array}{r} \\begin{array}{r} C(4)\\\\ C(9)\\\\ \\end{array} \\mathop{\\&} \\begin{array}{r} 100100100100100100...\\\\ 100110011001100110...\\\\ \\end{array} \\\\ \\hline \\begin{array}{r} 100100000000100100... \\end{array} \\end{array}You are given three integers l, r, and n. Among all numbers in the segment [l,r], find two integers x and y (l≤x<y≤r) such that C(x)&C(y) is lexicographically smallest, and print the first n binary symbols of this product.
设正整数 x>0 的闭包(closure)为如下无限二进制字符串 C(x):
- 将 x 写成不含前导零的二进制形式;
- 将所得字符串无限次地自我拼接,结果即为 C(x)。
例如:C(1)=11111…,C(4)=10010010010010…,C(9)=100110011001…。
定义两个闭包 C(x) 与 C(y) 的乘积 C(x)&C(y) 为对无限二进制字符串 C(x) 和 C(y) 逐位执行二进制按位与(bitwise AND)运算所得的无限二进制字符串。例如,对 C(4)&C(9),我们得到:
C(4)C(9)&100100100100100100…100110011001100110…100100000000100100…
给定三个整数 l、r 和 n。在区间 [l,r] 中的所有整数中,找出两个整数 x 和 y(满足 l≤x<y≤r),使得 C(x)&C(y) 的字典序最小,并输出该乘积的前 n 个二进制符号。
输入格式
The first line contains one integer t (1≤t≤1000) — the number of test cases.
The only line of each test case contains three integers l, r, and n (1≤l<r<230; 1≤n≤1000) — the range of possible values and the length of the answer.
第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例仅有一行,包含三个整数 l、r 和 n(1≤l<r<230;1≤n≤1000)—— 可能取值的范围以及答案的长度。
输出格式
For each test case, print one binary string of length n — the first n symbols of the lexicographically smallest product of closures.
对于每个测试用例,输出一个长度为 n 的二进制字符串——字典序最小的闭包乘积的前 n 个符号。
输入输出样例
输入#1
3 1 4 10 1073741822 1073741823 35 10 20 15
输出#1
1000001000 11111111111111111111111111111011111 100000000010000
说明/提示
In the first test case, the lexicographically smallest string is obtained by the product C(2)&C(4).
在第一个测试用例中,字典序最小的字符串由乘积 C(2)&C(4) 得到。
输入解题思路,AI测评打分。不知道怎么写?