Pagini recente » Cod sursa (job #1678459) | Cod sursa (job #2199136) | Cod sursa (job #1367240) | Cod sursa (job #1047630) | Cod sursa (job #311319)
Cod sursa(job #311319)
#include <fstream>
using namespace std;
#define NUME "inversmodular"
ifstream fi(NUME".in");
ofstream fo(NUME".out");
void gcd(long long &x, long long &y, int a, int b) {
if (!b)
x = 1, y = 0;
else
{
gcd(x, y, b, a % b);
long long t = y;
y = x - (a/b) * y;
x = t;
}
}
int main()
{
long long x, y;
int A, N;
fi >> A >> N;
gcd(x, y, A, N);
//while (
fo << x % N << endl;
return 0;
}