Cod sursa(job #3237289)
Utilizator | Data | 8 iulie 2024 09:13:04 | |
---|---|---|---|
Problema | Invers modular | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream F("inversmodular.in");
ofstream G("inversmodular.out");
#define L long long
L a,b,d,x,y;
void A(L a,L b,L *d,L *x,L *y)
{
if(!b)
*d=a,*x=1,*y=0;
else {
L e,f;
A(b,a%b,d,&e,&f),*x=f,*y=e-(a/b)*f;
}
}
int main()
{
return F>>a>>b,A(a,b,&d,&x,&y),G<<(y<0?b-y%b:y%b),0;
}