A problem with stairs

by hemangsarkar, Sep 11, 2015, 6:44 PM

This is a problem from Codeforces.
Q)
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?
Input:
The single line contains two space separated integers n, m (0 < n ≤ 10000, 1 < m ≤ 10).
Output:
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.

Solution
This post has been edited 1 time. Last edited by hemangsarkar, Sep 11, 2015, 6:45 PM

Comment

0 Comments

Archives
Shouts
Submit
  • I like shouting :lol:

    by boywholived, Sep 8, 2012, 12:02 PM

  • cool :lol:

    by subham1729, Sep 7, 2012, 6:44 AM

  • Awesome man !

    by Pheonix, Sep 6, 2012, 5:09 PM

3 shouts
Tags
About Owner
  • Posts: 791
  • Joined: Aug 4, 2011
Blog Stats
  • Blog created: Aug 12, 2011
  • Total entries: 69
  • Total visits: 15563
  • Total comments: 9
Search Blog