Cod sursa(job #1810193)
Utilizator | Data | 19 noiembrie 2016 18:47:06 | |
---|---|---|---|
Problema | Invers modular | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define in "inversmodular.in"
#define out "inversmodular.out"
using namespace std;
ifstream fin(in);
ofstream fout(out);
typedef unsigned long long ull;
int main()
{
ull a,n,x;
ull rez=0;
fin>>a>>n;
for(x=1; x<=n-1 && !rez; ++x)
if((a*x)%n ==1) rez=x;
fout<<rez<<"\n";
fin.close(); fout.close();
return 0;
}