Cod sursa(job #1717527)
Utilizator | Data | 14 iunie 2016 23:21:27 | |
---|---|---|---|
Problema | Invers modular | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int a, n;
f >> a;
f >> n;
int x = 1;
if ((a%n) != 0){
while (((a*x) % n) != 1)
++x;
g << x;
}
else
g << "Such a number does not exist";
f.close();
g.close();
return 0;
}