Turn Game 2
Time limit2sMemory limit512 MB
Decide whether turn wins of weights 1, 3, 5, ... can give Yunho x and Donghyeok y points, minimizing Yunho's wins.
- Level
Medium5 of 10
- Topics
- Math, Greedy, Number theory
- Solved
- No attempts yet
Problem
Yunho and Donghyeok are at an algorithm camp. When a problem will not come out, they take a break and play a game.
The game is made of turns, and each turn is won by one of the two players. Turns are numbered from 1, and the winner of turn earns points.
The total number of turns is not fixed. Any number of turns is possible, including zero.
You are given two integers and . Decide whether Yunho can end with points and Donghyeok with points. If that is possible, also find the smallest number of turns Yunho has to win.
Input
The first line contains two integers and . ()
Output
Print the smallest number of turns Yunho has to win. If scores and are impossible, print -1.