QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#16912. 美丽数组

统计

图像由 ChatGPT 4o 生成。

阿明的生日快到了,他的朋友阿美决定送他一个整数数组作为礼物。

阿明有两个最喜欢的数 $a$ 和 $b$,他认为如果一个数组的平均值恰好是 $a$ 且中位数恰好是 $b$,那么这个数组就是美丽的。请帮助阿美找到一个美丽数组,让她的礼物能给阿明留下深刻印象。

数组的平均值是其元素之和除以其长度。例如,数组 $[3, -1, 5, 5]$ 的平均值是 $12 \div 4 = 3$。

数组的中位数是将其排序后,若长度为奇数则为中间的元素,若长度为偶数则为中间两个元素的平均值。例如,$[1, 1, 2, 4, 8]$ 的中位数是 $2$,而 $[3, -1, 5, 5]$ 的中位数是 $(3 + 5) \div 2 = 4$。

注意,平均值和中位数不会被四舍五入为整数。例如,数组 $[1, 2]$ 的平均值是 $1.5$。

输入格式

唯一的一行包含两个整数 $a$ 和 $b$。

  • $-100 \le a, b \le 100$。
  • 数组的长度必须在 $1$ 到 $1000$ 之间。
  • 数组的元素必须是整数,且其绝对值不能超过 $10^6$。

输出格式

第一行输出一个整数,表示数组的长度。

第二行输出数组的元素,以空格分隔。

如果有多个解,你可以输出任意一个。可以证明,在题目的限制条件下,解总是存在的。

样例

输入样例 1

3 4

输出样例 1

4
3 -1 5 5

输入样例 2

-100 -100

输出样例 2

1
-100

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.