#P8869. Sign Transfer Function
Sign Transfer Function
Sign Transfer Function
Given two integers \(a\) and \(b\) (with \(b \neq 0\)), implement a function \(\operatorname{fun}(a, b)\) that transfers the sign of \(b\) to \(a\). The function is defined as:
\[ \operatorname{fun}(a, b) = \operatorname{sgn}(b) \times |a| \]
where \(\operatorname{sgn}(b)\) is defined as:
\[ \operatorname{sgn}(b)=\begin{cases}1 & \text{if } b>0\\ -1 & \text{if } b<0\end{cases} \]In other words:
- If \(b\) is positive, then \(\operatorname{fun}(a, b)=|a|\).
- If \(b\) is negative, then \(\operatorname{fun}(a, b)=-|a|\).
inputFormat
The input consists of two space-separated integers \(a\) and \(b\) (\(b \neq 0\)).
outputFormat
Output the result of \(\operatorname{fun}(a, b)\) which is an integer.
sample
3 2
3