Cod sursa(job #2050359)
Utilizator | Data | 28 octombrie 2017 09:33:21 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
#define ll long long
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
ll N,A;
void gcd(ll &x,ll&y,ll a,ll b)
{
if(b==0) {x=1;y=0;}
else
{
gcd(x,y,b,a%b);
ll aux=x;
x=y;
y=aux-y*(a/b);
}
}
int main()
{ll x,y;
f>>A>>N;
gcd(x,y,A,N);
g<<x;
return 0;
}