QOJ.ac

QOJ

実行時間制限: 4 s メモリ制限: 2048 MB 満点: 100

#5129. 音频均衡化

統計

作为 Balanced Audio Podcast © 的一名无线电工程师,你的工作是始终提供均衡的收听体验。你对听众进行了一项调查,他们特别关注响度的波动。为了解决这个问题,你购买了一个音频均衡变压器,但不幸的是,它的软件在运输过程中损坏了。

你的任务是重写这个均衡软件。变压器的输入是 $n$ 个振幅 $a_1, \dots, a_n$,其平均感知响度为 $\frac{1}{n} \sum_{i=1}^n a_i^2$。输出应包含相同的振幅,但要通过某个正的常数因子进行归一化,使得平均感知响度为 $x$。有一个例外:绝对的静音应始终保持不变。

输入格式

输入包含:

  • 一行包含两个整数 $n$ 和 $x$ ($1 \le n \le 10^5$, $0 \le x \le 10^6$),表示振幅的数量和要达到的平均感知响度。
  • 一行包含 $n$ 个整数 $a_1, \dots, a_n$ ($|a_i| \le 10^6$),表示振幅。

输出格式

输出一行包含 $n$ 个数字,即归一化后平均感知响度为 $x$ 的振幅。

你的答案的绝对误差或相对误差应不超过 $10^{-6}$。

样例

输入格式 1

5 6
0 1 -2 3 -4

输出格式 1

0 1 -2 3 -4

输入格式 2

4 1
1 3 3 7

输出格式 2

0.242535625 0.7276068751 0.7276068751 1.697749375

CC BY-SA 4.0 by Rburtonresearch on Wikipedia

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.