P8869 [ChuanZhi Cup #5 Preliminary] A - Lianzi’s Software Engineering
Background
Under the bombardment of cosmic rays, some of the functions that Lianzi had predefined on her computer were damaged.
For a science student, various software tools are very important in study and research. To restore the normal use of the software on her computer as soon as possible, she needs to rewrite some of these functions quickly.
Description
Specifically, given two integers $a, b$, with $b \neq 0$ guaranteed, Lianzi wants to implement a function $\operatorname{fun}(a,b)$ that transfers the sign of $b$ onto $a$.
More precisely, $\operatorname{fun}(a,b)=\operatorname{sgn}(b)\times |a|$, where $\operatorname{sgn}(b)=\begin{cases}1&b>0\\-1&b
Input Format
- A single line containing two integers $a, b$.
Output Format
- A single line containing one integer, the value of $\operatorname{fun}(a,b)$.
Explanation/Hint
For all testdata, $a$ and $b$ are within the range of 32-bit signed integers, and $b \neq 0$.
Translated by ChatGPT 5