Pagini recente » Cod sursa (job #338849) | Cod sursa (job #1381297) | Cod sursa (job #642927) | Cod sursa (job #1336846) | Cod sursa (job #2130974)
#include <bits/stdc++.h>
using namespace std;
ifstream fi("inversmodular.in");
ofstream fo("inversmodular.out");
void euclidex(int a, int b, long long &x, long long &y){
if(b == 0){
x = 1;
y = 0;
return;
}
euclidex(b, a % b, x, y);
long long aux = y;
y = x - 1LL * (a / b) * y;
x = aux;
}
int main()
{
int a, b;
fi >> a >> b;
long long x, y;
euclidex(a, b, x, y);
x = (x + b) % b;
fo << x;
return 0;
}