Cod sursa(job #1006844)
Utilizator | Data | 7 octombrie 2013 20:35:07 | |
---|---|---|---|
Problema | Invers modular | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
ifstream is("inversmodular.in");
ofstream os("inversmodular.out");
int Modul( int N, int A );
int main()
{
int N, A;
is >> N >> A;
os << Modul ( N, A );
is.close();
os.close();
return 0;
}
int Modul( int N, int A )
{
int x = 0, y;
for ( y = 0; x == 0; y++ )
if ( ( N * y + 1 ) % A == 0 )
x = ( N * y + 1 ) / A;
return x;
}