Mai intai trebuie sa te autentifici.
Cod sursa(job #229062)
| Utilizator | Data | 9 decembrie 2008 07:12:20 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include<fstream>
using namespace std;
void cmmdc(int a, int b, int &d, int &x, int &y){
if(b){
cmmdc(b,a%b,d,x,y);
int aux=y;
y=x-b*(a/b)*y;
x=aux;
}
else
{
d=a;
x=1;
y=0;
}
}
int main()
{
int n, a,p, d,x,y;
ifstream f("inversmodular.in");
f>>a>>n;
f.close();
cmmdc(a,n,d,x,y)
ofstream g("inversmodular.out");
g<<x<<'\n';
g.close();
return 0;
}
