Pagini recente » Cod sursa (job #2585126) | Cod sursa (job #3139607) | Cod sursa (job #1850387) | Cod sursa (job #1435093) | 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;
}