Problem list
Log in
#icpc00342 · ICPC BAPC 2022

Equalising Audio

Silver III 4.0 s 2048 MB

As a radio engineer at the Balanced Audio Podcast your job is to deliver an equal listening experience at all times. You did a poll among the listeners and they are especially concerned about fluctuations in loudness. To resolve this you bought a transformer to equalise the audio, but alas, its software got corrupted during transport.

Your job is to rewrite the equalising software. As input the transformer gets $n$ amplitudes $a_1, \ldots, a_n$, with an average perceived loudness of $\frac{1}{n}\sum_{i=1}^n a_i^2$. The output should contain the same amplitudes, but renormalised by some constant positive factor, such that the average perceived loudness is $x$. There is one exception: total silence should always be preserved.

Input

The input consists of:

  • One line with a two integers $n$ and $x$ ($1\leq n\leq 10^5$, $0 \leq x \leq 10^6)$, the number of amplitudes and the average perceived loudness to achieve.
  • One line with $n$ integers $a_1, \ldots, a_n$ ($\left| a_i \right| \leq 10^6$), the amplitudes.

Output

Output one line containing $n$ numbers, the renormalised amplitudes with an average perceived loudness of $x$.

Your answers should have an absolute or relative error of at most $10^{-6}$.

Example 1

Input
5 6
0 1 -2 3 -4
Output
0 1 -2 3 -4

Example 2

Input
4 1
1 3 3 7
Output
0.242535625 0.7276068751 0.7276068751 1.697749375
Source
ICPC BAPC 2022
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 1 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code