A - Find Multiple
Editorial
/


Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
A 以上 B 以下であるような C の倍数を、1 つ出力してください。
条件を満たす数が存在しない場合は -1
を出力してください。
制約
- 1 \leq A \leq B \leq 1000
- 1 \leq C \leq 1000
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
A B C
出力
答えを出力せよ。
条件を満たす数が存在しない場合は -1
を出力せよ。
入力例 1
123 456 100
出力例 1
200
300
や 400
も正解です。
入力例 2
630 940 314
出力例 2
-1
Score : 100 points
Problem Statement
Print a number between A and B (inclusive) that is a multiple of C.
If there is no such number, print -1
.
Constraints
- 1 \leq A \leq B \leq 1000
- 1 \leq C \leq 1000
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C
Output
Print the answer.
If there is no number with the desired property, print -1
.
Sample Input 1
123 456 100
Sample Output 1
200
300
or 400
would also be accepted.
Sample Input 2
630 940 314
Sample Output 2
-1