Pagini recente » Cod sursa (job #1047988) | Cod sursa (job #2115657) | Cod sursa (job #704093) | Cod sursa (job #1415131) | Cod sursa (job #2725397)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
void euclid(int a, int b, int &x, int &y) {
if(b == 0)
x = y = 1;
else {
int x1, y1;
euclid(b, a % b, x1, y1);
x = y1;
y = x1 - (a/b) * y1;
}
}
int main() {
int a, n; fin >> a >> n;
int x, y;
if(n > a)
swap(a, n);
euclid(a, n, x, y);
fout << x;
}