Euclid Problem#1155

Euclid Problem

1 segundo
128 megabytes
Muy fácil

From Euclid, it is known that for any positive integers and , there exist integers and such that a \cdot x + b \cdot y = d, where is the greatest common divisor of and .

Given and , find such integers , , and .

Entrada

Each line contains two positive integers and (a, b \le 10^9).

Salida

For each input pair and , output three integers , , and separated by spaces on a single line. If there are multiple such pairs, output the one where |x| + |y| is minimized. If there are still multiple solutions, output the one with the smallest .

Ejemplos

Ejemplo 1

Loading
Loading