302470: CF476A. Dreamoon and Stairs
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Dreamoon and Stairs
题意翻译
题面 DM小朋友想要上一个有 $n$ 级台阶的楼梯。他每一步可以上 $1$ 或 $2$ 级台阶。假设他走上这个台阶一共用了 $x$ 步。现在DM想知道 $x$ 是否可能为 $m$ 的倍数。如果可能,输出 $x$ 的最小值。如果不可能,输出 $-1$ 输入 两个正整数 $n,m\ \ (n<=10000,m<=10)$ 输出 按要求输出 $x$ 或 $-1$ 感谢@FCBM71 提供的翻译题目描述
Dreamoon wants to climb up a stair of $ n $ steps. He can climb $ 1 $ or $ 2 $ steps at each move. Dreamoon wants the number of moves to be a multiple of an integer $ m $ . What is the minimal number of moves making him climb to the top of the stairs that satisfies his condition?输入输出格式
输入格式
The single line contains two space separated integers $ n $ , $ m $ ( $ 0<n<=10000,1<m<=10 $ ).
输出格式
Print a single integer — the minimal number of moves being a multiple of $ m $ . If there is no way he can climb satisfying condition print $ -1 $ instead.
输入输出样例
输入样例 #1
10 2
输出样例 #1
6
输入样例 #2
3 5
输出样例 #2
-1