Cod sursa(job #2370064)
| Utilizator | Data | 6 martie 2019 10:33:35 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
std::ifstream f ("inversmodular.in");
std::ofstream g ("inversmodular.out");
using namespace std;
int gcd(int a, int c) {
int b;
int r;
g << a << ' ' << c << ' ';
if (c == 0) {
return a;
}
else if (c == 1) {
return c;
}
b = a/c;
r = a%c;
g << r << '\n';
gcd(c, r);
}
int main()
{
int n, m;
f >> n >> m;
cout << gcd(n, m);
return 0;
}
