QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#9133. 具有多个最大值的函数

统计

对于一个正整数 $a > 0$,定义函数 $f_a : \mathbb{Z}_{\ge 0} \to \mathbb{Z}$ 为:

$$f_a(x) = \begin{cases} a + x, & \text{if } x \le a \\ 0, & \text{otherwise} \end{cases}$$

给定一个正整数 $b$。请构造一个包含不同整数的非空集合 $a_1, a_2, \dots, a_n$,使得函数 $f(x) = \sum_{i=1}^n f_{a_i}(x)$ 至少有 $b$ 个点取到最大函数值。形式化地:

$$\left| \left\{ x \in \mathbb{Z}_{\ge 0} : f(x) = \max_{y \in \mathbb{Z}_{\ge 0}} f(y) \right\} \right| \ge b$$

输入格式

仅一行,包含一个整数 $b$ ($1 \le b \le 100\,000$)。

输出格式

第一行输出一个整数 $n$ ($1 \le n \le 500\,000$),表示数组 $a$ 的大小。 第二行输出 $n$ 个不同的整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^{12}$)。

题目保证在给定约束下解一定存在。如果存在多个答案,输出任意一个即可。

样例

输入 1

4

输出 1

5
2 3 5 10 12

说明

在第一个测试样例中,$f(x) = f_2(x) + f_3(x) + f_5(x) + f_{10}(x) + f_{12}(x)$。最大值为 $\max_{y \in \mathbb{Z}_{\ge 0}} f(y) = 42$。我们有 4 个点取到最大值,即 $f(2) = f(3) = f(5) = f(10) = 42$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.