#P12572. [UOI 2023] An Array and Addition Again

    ID: 14139 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>2023Special Judge构造UOI(乌克兰)

[UOI 2023] An Array and Addition Again

题目描述

Given an array aa with elements numbered from 11 to 100100. Initially, ai=0a_i = 0 for 1i<1001 \leq i < 100, and the last element a100a_{100} is equal to 11.

The array aa can be modified using increment operations. To perform mm increment operations, it is necessary to select mm integers p1,p2,,pmp_1, p_2, \dots, p_m (1pi<1001\le p_i < 100) and sequentially execute assignments api(api+api+1)a_{p_i} \leftarrow (a_{p_i} + a_{p_i + 1}) for ii from 11 to mm.

Given an integer nn, find the sequence of increment operations after which the element at the first position in array aa becomes equal to nn.

输入格式

The first line contains two integers tt and gg (1t1001 \le t \le 100, 0g50 \leq g \leq 5) --- the number of input sets and the test block number, respectively.

In the next tt lines, there is a single integer nn (1n10181 \le n \le 10^{18}) --- the value that a1a_1 should be equal to after performing the increment operations in the corresponding set.

输出格式

For each set of input data, output one integer mm (0m20000 \leq m \leq 2000) in the first line --- the number of increase operations.

In the second line, output mm integers pip_i (1pi<1001 \le p_i < 100) --- the parameters of the increase operations.

If there are multiple correct answers, you can output any of them.

1 0
1
99
99 98 ... 7 6 5 4 3 2 1
2 0
3
16
101
99 98 ... 7 6 5 4 3 2 1 1 1
103
99 98 ... 7 6 5 4 4 3 3 2 2 1 1

提示

For clarity, the examples of the input data in the problem statement have been reduced. To obtain the correct answer, replace ...\tt{...} with the sequence of integers from 9797 to 88.

Let's consider the second set of input data for the second example, where n=16n = 16. The first 8 elements of the array aa after performing the next operation look as follows:

  • p1p_1 = 99, a=[0,0,0,0,0,0,0,0,,0,0,1,1]a = [0, 0, 0, 0, 0, 0, 0, 0, \ldots, 0, 0, 1, 1];
  • p2p_2 = 98, a=[0,0,0,0,0,0,0,0,,0,1,1,1]a = [0, 0, 0, 0, 0, 0, 0, 0, \ldots, 0, 1, 1, 1];
  • \ldots
  • p93=7p_{93} = 7, a=[0,0,0,0,0,0,1,1,,1,1,1,1]a = [0, 0, 0, 0, 0, 0, 1, 1, \ldots, 1, 1, 1, 1];
  • p94=6p_{94} = 6, a=[0,0,0,0,0,1,1,1,,1,1,1,1]a = [0, 0, 0, 0, 0, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p95=5p_{95} = 5, a=[0,0,0,0,1,1,1,1,,1,1,1,1]a = [0, 0, 0, 0, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p96=4p_{96} = 4, a=[0,0,0,1,1,1,1,1,,1,1,1,1]a = [0, 0, 0, 1, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p97=4p_{97} = 4, a=[0,0,0,2,1,1,1,1,,1,1,1,1]a = [0, 0, 0, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p98=3p_{98} = 3, a=[0,0,2,2,1,1,1,1,,1,1,1,1]a = [0, 0, 2, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p99=3p_{99} = 3, a=[0,0,4,2,1,1,1,1,,1,1,1,1]a = [0, 0, 4, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p100=2p_{100} = 2, a=[0,4,4,2,1,1,1,1,,1,1,1,1]a = [0, 4, 4, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p101=2p_{101} = 2, a=[0,8,4,2,1,1,1,1,,1,1,1,1]a = [0, 8, 4, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p102=1p_{102} = 1, a=[8,8,4,2,1,1,1,1,,1,1,1,1]a = [8, 8, 4, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1];
  • p103=1p_{103} = 1, a=[16,8,4,2,1,1,1,1,,1,1,1,1]a = [16, 8, 4, 2, 1, 1, 1, 1, \ldots, 1, 1, 1, 1].

Scoring

The first four test blocks allow using no more than 300 increment operations.

  • (44 points): n100n \leq 100;
  • (66 points): n=k2n = k^2 for some integer 1k1001 \le k \le 100;
  • (1010 points): n=(2k1)n = (2^k - 1) for some integer kk;
  • (1313 points): nn is a Fibonacci number (i.e., nn is an element of the sequence where each element is the sum of the two previous ones: 1,1,2,3,5,8,13,21,34,1, 1, 2, 3, 5, 8, 13, 21, 34, \dots);
  • (up to 6767 points): without additional restrictions. Let the maximum number of increment operations used be cc. If c300c \le 300, you will receive 6767 points, otherwise you will receive ($17 + \left \lfloor \frac{2000 - c}{34} \right \rfloor$) points.

The C++\tt{C++} code that calculates the number of points for the last test block depending on the number of increment operations used is:

((c <= 300) ? 67 : (17 + (2000 - c) / 34))