Pagini recente » Cod sursa (job #1190431) | Cod sursa (job #1375918) | Atasamentele paginii Coding Contest Byte: The Square Root Trick | Cod sursa (job #1051010) | Cod sursa (job #1386190)
#include <iostream>
#include <fstream>
using namespace std;
long long x,y,a,b;
void gcd(int a, int b)
{
if(b==0)
x=1,y=0;
else
{
gcd(b,a%b);
long long aux=x;
x=y;
y=aux- y*(a/b);
}
}
int main()
{
ifstream in("inversmodular.in");
ofstream out("inversmodular.out");
in >> a >> b;
gcd(a,b);
if(x<0)
x=b+x%b;
out << x;
return 0;
}