Cod sursa(job #2044496)
Utilizator | Data | 21 octombrie 2017 10:39:58 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int a, n, k, l;
void euclid(int a, int b, int &x,int &y)
{
if(!b)
{
x = 1;
y = 0;
return;
}
int x1, y1;
euclid(b, a%b, x1, y1);
x = y1;
y = x1 - (a/b) * y1;
}
int main()
{
f>>a;
f>>n;
euclid(a,n,k,l);
g<<k;
return 0;
}