Pagini recente » Cod sursa (job #1611041) | Cod sursa (job #1085608) | Cod sursa (job #1060583) | Cod sursa (job #1272457) | Cod sursa (job #229065)
Cod sursa(job #229065)
#include<fstream>
using namespace std;
void cmmdc(int a, int b, long long &x, long long &y){
if(b){
cmmdc(b,a%b,x,y);
int aux=y;
y=x-(a/b)*y;
x=aux;
}
else
{
x=1;
y=0;
}
}
int main()
{
int n, a, x, y;
ifstream f("inversmodular.in");
f>>a>>n;
f.close();
cmmdc(a,n,x,y);
ofstream g("inversmodular.out");
g<<x<<'\n';
g.close();
return 0;
}