CF2242E.Product of Closures

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let the closure of a positive integer x>0x \gt 0 be the following infinite binary string C(x)C(x):

  1. Write xx in binary form without leading zeros;
  2. Concatenate the obtained string with itself infinitely many times and call the result C(x)C(x).

For example, C(1)C(1) == 11111..., C(4)C(4) == 10010010010010..., C(9)C(9) == 100110011001....

Let the product of two closures C(x)&C(y)C(x) \mathop{\&} C(y) be the infinite binary string obtained by the bitwise binary AND of the strings C(x)C(x) and C(y)C(y). For example, for C(4)&C(9)C(4) \mathop{\&} 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 ll, rr, and nn. Among all numbers in the segment [l,r][l, r], find two integers xx and yy (l≤x<y≤rl \le x \lt y \le r) such that C(x)&C(y)C(x) \mathop{\&} C(y) is lexicographically smallest, and print the first nn binary symbols of this product.

设正整数 x>0x > 0 的闭包(closure)为如下无限二进制字符串 C(x)C(x):

  1. 将 xx 写成不含前导零的二进制形式;
  2. 将所得字符串无限次地自我拼接,结果即为 C(x)C(x)。

例如:C(1)=11111…C(1) = 11111\ldots,C(4)=10010010010010…C(4) = 10010010010010\ldots,C(9)=100110011001…C(9) = 100110011001\ldots。

定义两个闭包 C(x)C(x) 与 C(y)C(y) 的乘积 C(x)&C(y)C(x) \mathop{\&} C(y) 为对无限二进制字符串 C(x)C(x) 和 C(y)C(y) 逐位执行二进制按位与(bitwise AND)运算所得的无限二进制字符串。例如,对 C(4)&C(9)C(4) \mathop{\&} C(9),我们得到:

C(4)C(9)&100100100100100100…100110011001100110…100100000000100100…\begin{array}{r} \begin{array}{r} C(4)\\ C(9)\\ \end{array} \mathop{\&} \begin{array}{r} 100100100100100100\ldots\\ 100110011001100110\ldots\\ \end{array} \\ \hline \begin{array}{r} 100100000000100100\ldots \end{array} \end{array}

给定三个整数 ll、rr 和 nn。在区间 [l,r][l, r] 中的所有整数中,找出两个整数 xx 和 yy(满足 l≤x<y≤rl \le x < y \le r),使得 C(x)&C(y)C(x) \mathop{\&} C(y) 的字典序最小,并输出该乘积的前 nn 个二进制符号。

输入格式

The first line contains one integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

The only line of each test case contains three integers ll, rr, and nn (1≤l<r<2301 \le l \lt r \lt 2^{30}; 1≤n≤10001 \le n \le 1000) — the range of possible values and the length of the answer.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例仅有一行,包含三个整数 ll、rr 和 nn(1≤l<r<2301 \le l \lt r \lt 2^{30};1≤n≤10001 \le n \le 1000)—— 可能取值的范围以及答案的长度。

输出格式

For each test case, print one binary string of length nn — the first nn symbols of the lexicographically smallest product of closures.

对于每个测试用例,输出一个长度为 nn 的二进制字符串——字典序最小的闭包乘积的前 nn 个符号。

输入输出样例

  • 输入#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) \mathop{\&} C(4).

在第一个测试用例中,字典序最小的字符串由乘积 C(2)&C(4)C(2) \mathop{\&} C(4) 得到。

输入解题思路,AI测评打分。不知道怎么写?

首页