#P7258. Mirko’s Rounding Check
Mirko’s Rounding Check
Mirko’s Rounding Check
Mirko can only pay using bills of denominations \(1, 10, 10^2, 10^3, \ldots, 10^9\). One day, he tells the shop owner that the smallest bill he has is \(a\) and wants to buy an item costing \(p\) units. The shop owner then rounds \(p\) to the nearest multiple of \(a\) using the standard rounding rule (i.e. if the remainder is at least \(\frac{a}{2}\), round up; otherwise, round down). For example, if \(a=100\) and \(p=150\), the rounded amount will be \(200\) (since \(150\) is exactly halfway, and we round up), and if \(p=149\) then it will be \(100\).
Mirko is suspicious that the shop owner might have cheated him by charging an incorrect rounded amount. Given the values of \(a\), \(p\), and the amount \(r\) that the shop owner charged, determine whether the shop owner charged the correct amount according to the agreed rounding rule.
The correct rounding is computed as follows:
[ \text{rounded} = \begin{cases} \left(\left\lfloor \frac{p}{a} \right\rfloor + 1\right) \times a & \text{if } 2\times(p \bmod a) \ge a,\ \left\lfloor \frac{p}{a} \right\rfloor \times a & \text{otherwise.} \end{cases} ]
</p>inputFormat
The input consists of a single line containing three space-separated integers:
- \(a\): the smallest bill denomination Mirko has (one of \(1, 10, 10^2, \ldots, 10^9\)).
- \(p\): the actual price of the item.
- \(r\): the amount the shop owner charged him.
outputFormat
Output true
if the shop owner charged the correct amount according to the rounding rule; otherwise, output false
.
sample
100 150 200
true