「CodeForces 476A」Dreamoon and Stairs 暴力枚举

「CodeForces 476A」Dreamoon and Stairs 暴力枚举

原题链接

题意翻译
题面 DM小朋友想要上一个有 n 级台阶的楼梯。他每一步可以上 1 或 2 级台阶。假设他走上这个台阶一共用了 x 步。现在DM想知道 x 是否可能为 m 的倍数。如果可能,输出 x 的最小值。如果不可能,输出 −1
输入 两个正整数 n,m(n≤10000,m≤10)
输出 按要求输出 x 或 −1

题目描述
Dreamoon wants to climb up a stair of nn 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值