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