Cod sursa(job #919077)
Utilizator | Data | 19 martie 2013 12:50:45 | |
---|---|---|---|
Problema | Invers modular | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int a, n, y = 0;
bool gasit = false;
f>>a>>n;
while(!gasit) {
y++;
if( (1LL*(a * y)) % n == 1 ) gasit = true;
}
g<<y<<"\n";
cout<<y<<"\n";
return 0;
}