406015: GYM102218 H Heartbreaker Radio Station

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Heartbreaker Radio Stationtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Studying at ESCOM is not easy, sometimes you can feel a stressful environment almost everywhere! But to get over it, our friend Laura and her boyfriend Lalo decided to create a local radio station called Heartbreaker, where they transmit news about the daily life in ESCOM, some good music and podcasts too.

To make that possible, Lalo concluded that they will need to transmit $$$n$$$ sinusoidal waves with the same angular frequency $$$\omega$$$ (in $$$\text{rad}/\text{s}$$$), each with his own amplitude $$$A_i$$$ and phase $$$\phi_i$$$ (in $$$\text{rad}$$$). That is, the $$$i^{th}$$$ wave will be of the form $$$f_i(t)=A_i \sin(\omega t + \phi_i)$$$, and they will transmit the new wave given by the sum $$$f(t)=f_1(t)+f_2(t)+\cdots+f_n(t)$$$.

But suddenly Laura notices that it will be very expensive to transmit all these $$$n$$$ waves at the same time, so she thinks of the wonderful fact that they can find another single sinusoidal wave with the same frequency of the form $$$A \sin(\omega t + \phi)$$$ which is equivalent to transmit each of the $$$n$$$ waves individually, so they will only have to transmit one wave! Help them to find that mysterious wave.

Input

The first line contains two values: the integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) and the angular frequency $$$\omega$$$ of all the waves given by a real number $$$(0.1 \leq \omega \leq 100)$$$.

The next $$$n$$$ lines contain two real numbers $$$A_i$$$ ($$$0.1 \leq A_i \leq 100$$$) and $$$\phi_i$$$ ($$$0 \leq \phi_i < 2\pi$$$), indicating the amplitude and the phase of the $$$i^{th}$$$ wave.

Output

Output one line with two real values: $$$A$$$ ($$$A \geq 0$$$) and $$$\phi$$$ ($$$0 \leq \phi < 2\pi$$$), the amplitude and the phase of the resulting wave. The absolute or relative error of the answers should not exceed $$$10^{-6}$$$.

ExampleInput
8 66.82
93.22 5.53
48.58 0.86
15.31 5.39
5.66 4.12
48.53 6.09
6.60 1.42
21.15 0.06
4.27 5.47
Output
185.184472750 6.019915094

加入题单

算法标签: