#P8869. [传智杯 #5 初赛] A-莲子的软件工程学
[传智杯 #5 初赛] A-莲子的软件工程学
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.
Problem Description
Specifically, given two integers , with guaranteed, Lianzi wants to implement a function that transfers the sign of onto .
More precisely, $\operatorname{fun}(a,b)=\operatorname{sgn}(b)\times |a|$, where $\operatorname{sgn}(b)=\begin{cases}1&b>0\\-1&b<0\end{cases}$.
In other words:
- If is positive, then .
- If is negative, then .
Input Format
- A single line containing two integers .
Output Format
- A single line containing one integer, the value of .
-1 2
1
0 -4
0
-12345 -54321
-12345
Hint
For all testdata, and are within the range of 32-bit signed integers, and .
Translated by ChatGPT 5