Cod sursa(job #1006506)
Utilizator | Data | 7 octombrie 2013 10:27:52 | |
---|---|---|---|
Problema | Invers modular | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream is("inversmodular.in");
ofstream os("inversmodular.out");
int n, a, x;
void Mod();
int main()
{
is >> a >> n;
Mod();
os << x;
is.close();
os.close();
return 0;
}
void Mod()
{
for ( int i = 1; i < n-1; ++i )
if ( (a*i) % n == 1 )
{
x = i;
return;
}
}