Pagini recente » Cod sursa (job #2029432) | Cod sursa (job #162976) | Cod sursa (job #1954795) | Cod sursa (job #2579545) | Cod sursa (job #229068)
Cod sursa(job #229068)
#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);
long long aux=y;
y=x-(a/b)*y;
x=aux;
}
else
{
x=1;
y=0;
}
}
int main()
{
int n, a;
long long 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;
}