P2252 [Template] Wythoff Game / [SHOI2002] Take Stones Game

Description

There are two piles of stones, with arbitrary (possibly different) counts. Two players take turns. Each move is one of the following: - Remove any number of stones from exactly one pile. - Remove the same number of stones from both piles simultaneously. The player who takes the last stones wins. Given the initial numbers of stones in the two piles, you move first. Assuming both players play optimally, determine whether you will win or lose.

Input Format

The input consists of a single line. The only line contains two integers $a, b$, representing the initial numbers of stones.

Output Format

The output consists of a single line. Output a single integer $1$, $0$, or $-1$: output $1$ if you will win; output $0$ if you will lose; output $-1$ if the result cannot be determined.

Explanation/Hint

Constraints $50\%$ of the testdata satisfy $a, b \le 1000$. $100\%$ of the testdata satisfy $a, b \le 10^9$. Translated by ChatGPT 5