Pagini recente » Cod sursa (job #477191) | Cod sursa (job #878816) | Cod sursa (job #1868415) | Cod sursa (job #1516722) | Cod sursa (job #2744951)
#include <iostream>
#include <fstream>
using namespace std;
void euclid( int a, int b, int& x, int& y ) {
if ( b == 0 ) {
x = 1;
y = 0;
} else {
int x0, y0;
euclid( b, a % b, x0, y0 );
x = y0;
y = x0 - (int)( a / b ) * y0;
}
}
int main() {
ifstream fin( "inversmodular.in" );
ofstream fout( "inversmodular.out" );
int a, b, x, y;
fin >> a >> b;
euclid( a, b, x, y );
fout << x;
return 0;
}