Pagini recente » Cod sursa (job #2303739) | Cod sursa (job #1356807) | Statistici Cretu Beatrice Denisa (cretu.bbeatrice) | Borderou de evaluare (job #2921991) | Cod sursa (job #1595441)
#include <fstream>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int A,N;
void c(long long &x,long long &y,int a, int b)
{ if(b==0) {x=1;y=0;}
else{ c(x,y,b,a%b);
long long aux=x;
x=y;
y=aux-y*(a/b);
}
}
int main()
{ long long l=0,m;
f>>A>>N;
c(l,m,A,N);
if (l<=0) l=N+l%N;
g<<l;
return 0;
}