# 110703 Euclid problem

import java.util.*;

public class Main {

private static void EuclidAlgorithm(int a, int b)
{
if (a < b)
{
EuclidAlgorithm(b, a);
int temp = ResultX;
ResultX = ResultY;
ResultY = temp;
return;
}

if (b == 0)
{
ResultX = 1;
ResultY = 0;
ResultGCD = a;
return;
}

int floor = a / b;
EuclidAlgorithm(b, a - b * floor);
int tempX = ResultX;
int tempY = ResultY;
ResultX = tempY;
ResultY = tempX - tempY * floor;
return;
}

private static void OutputEuclidNumbers(int a, int b)
{
EuclidAlgorithm(a, b);
System.out.println(ResultX + " " + ResultY + " " + ResultGCD);
}

public static void main(String[] args){
Scanner inScanner = new Scanner(System.in);
while(inScanner.hasNextInt())
{
int a = inScanner.nextInt();
int b = inScanner.nextInt();
OutputEuclidNumbers(a, b);
}
}

private static int ResultX;
private static int ResultY;
private static int ResultGCD;
}

#### PC/UVa 题号： 110703/1014 Euclid Problem

2012-02-27 14:53:59

#### Euclid开源源码解析

2015-11-06 15:15:11

#### 求最大公约数的欧几里德算法(Euclid's Algorithm)

2007-01-07 08:27:00

#### HDU1525 Euclid's Game (找规律博弈)

2017-04-30 21:44:14

#### Intel Euclid （一）

2018-03-26 19:05:40

#### Euclid空间上的点集划分

2017-11-01 17:30:54

#### uva 10368 - Euclid's Game(博弈)

2014-07-02 19:56:10

#### Euclid 算法

2007-06-01 16:14:00

#### euclid's algorithm

2012-05-18 01:42:22

#### Euclid算法

2010-03-22 17:21:00