No.2259 Gas Station
タグ : / 解いたユーザー数 222
作問者 :
sotanishy
/ テスター :
milkcoffee
Problem Statement
At a gas station, you choose an integer $x$ between $L$ and $R$, inclusive, and fill up with $x$ liters of gasoline. Gasoline costs $C$ yen per $1$ liter. You have an infinite number of $1000$-yen bills. Choose the amount of fuel appropriately and find the minimum possible change when paying using only $1000$-yen bills.
Input
$L$ $R$ $C$
- $1 \leq L \leq R \leq 10^9$
- $1 \leq C \leq 10^9$
- All inputs are integers.
Output
Output the minimum achievable change on $1$ line. Print a newline at the end.
Sample
Sample 1
Input
1 3 400
Output
200
When you buy $1,2,3$ liters, the costs are $400,800,1200$ yen and the change is $600,200,800$ yen, respectively. The minimum of these, $200$, is the answer.
Sample 2
Input
4 6 200
Output
0
Sample 3
Input
100 100 1
Output
900
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。