Pagini recente » Cod sursa (job #1112445) | Autentificare | Arhiva de probleme | Istoria paginii runda/eusebiu_oji_2012_cls11-12/clasament | Cod sursa (job #1609916)
#include <fstream>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
void inversmodular (long long &x,long long &y,long long a,long long b)
{
int aux;
if(b==0)
{
x=1; y=0;
}
else
{
inversmodular(x,y,b,a%b);
aux=x;
x=y;
y=aux-y*(a/b);
}
}
int main()
{
long long x,y,a,b;
f>>a>>b;
inversmodular(x,y,a,b);
if(x<0) x=b+x%b;
g<<x;
return 0;
}