Pagini recente » Cod sursa (job #639949) | Cod sursa (job #3196676) | Cod sursa (job #1922768) | Cod sursa (job #395596) | Cod sursa (job #1917005)
#include <bits/stdc++.h>
using namespace std;
void gcd(long long& x, long long& y, long long a, long long b){
if(b){
gcd(x, y, b, a%b);
long k = x;
x = y;
y = k - y*(a/b);
}
else{
x = 1;
y = 0;
}
}
int main()
{
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
long long i, sol, q, a, n;
f >> a >> n;
gcd(sol, q, a, n);
g << sol << "\n";
}