Daya,Doors and breaking
Daya from CID wants to break n consecutive doors.He will break only 2 doors or 1 door in a single kick.
ACP's condition is that number of kicks must be a multiple of k .
Find minimal number of kicks so Daya can break all gates that satisfies ACP's condition?
print -1 if not possible.
INPUT
- First line of input contains two integer n and k .
OUTPUT
- Output a single integer denoting the answer if it is not possible to find an answer satisfying the conditions then print -1 instead.
CONSTRAINTS
Explanation
Daya's door optimal breaking sequence can be 2,2,2,2,1,1
So total kicks ( 6 ) is a multiple of 2.
Time Limit:
1.0 sec(s)
for each input file.
Memory Limit:
256 MB
Source Limit:
1024 KB
Marking Scheme:
Marks are awarded when all the testcases pass.
Allowed Languages:
C,
C++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Scala 2.11.8,
Swift,
Visual Basic