#P4893. Dreamoon and Stairs
Dreamoon and Stairs
Dreamoon and Stairs
题面翻译
题面 DM小朋友想要上一个有 级台阶的楼梯。他每一步可以上 或 级台阶。假设他走上这个台阶一共用了 步。现在DM想知道 是否可能为 的倍数。如果可能,输出 的最小值。如果不可能,输出 输入 两个正整数 输出 按要求输出 或
感谢@FCBM71 提供的翻译
题目描述
Dreamoon wants to climb up a stair of steps. He can climb or steps at each move. Dreamoon wants the number of moves to be a multiple of an integer .
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 , ( ).
输出格式
Print a single integer — the minimal number of moves being a multiple of . If there is no way he can climb satisfying condition print instead.
样例 #1
样例输入 #1
10 2
样例输出 #1
6
样例 #2
样例输入 #2
3 5
样例输出 #2
-1
提示
For the first sample, Dreamoon could climb in 6 moves with following sequence of steps: {2, 2, 2, 2, 1, 1}.
For the second sample, there are only three valid sequence of steps {2, 1}, {1, 2}, {1, 1, 1} with 2, 2, and 3 steps respectively. All these numbers are not multiples of 5.