#B4258. Rounding to the Nearest Ten
Rounding to the Nearest Ten
Rounding to the Nearest Ten
This problem involves rounding integers to the nearest multiple of ten. Given n integers, your task is to round each integer according to the round half up rule: if the last digit of an integer is 5 or more, round up to the next multiple of ten; otherwise, round down.
For example, rounding 43
gives 40
, and rounding 58
gives 60
. The mathematical operation can be described using the following formula:
\[ \text{result} = \begin{cases} x - (x \bmod 10), & \text{if } x \bmod 10 < 5, \\ x + (10 - (x \bmod 10)), & \text{if } x \bmod 10 \geq 5. \end{cases} \]
inputFormat
The first line contains an integer n
, representing the number of integers. The second line contains n
integers separated by spaces.
outputFormat
Output a single line containing n
integers, each representing the rounded value of the corresponding input integer. The rounded integers should be separated by a single space.
sample
2
43 58
40 60