Cod sursa(job #2758855)
| Utilizator | Data | 13 iunie 2021 18:13:42 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
using namespace std;
const string name("inversmodular");
ifstream cin(name + ".in");
ofstream cout(name + ".out");
void Euclid(long long a, long long b, long long &x, long long &y){
if(!b)
x = 1, y = 1;
else{
long long x1, y1;
Euclid(b, a % b, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int main(){
long long a, n;
cin >> a >> n;
long long x, y;
Euclid(a, n, x, y);
cout << y;
return 0;
}
