Cod sursa(job #1872373)
| Utilizator | Data | 8 februarie 2017 10:19:42 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
long long a,n,x,y;
void euclid(long long a,long long b,long long &x,long long &y)
{
if(b==0)
{
x=1;
y=0;
}
else
{
long long x0,y0;
euclid(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
f>>a>>n;
euclid(a,n,x,y);
g<<x;
f.close();
g.close();
return 0;
}
