Cod sursa(job #2639481)
| Utilizator | Data | 2 august 2020 13:16:05 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("inversmodular.in");
ofstream out("inversmodular.out");
unsigned int A,N;
unsigned long long B1,B2;
int main()
{
in>>A>>N;
for(int i=1; i*N+1<=0xffffffffffffffff; i++)
{
B1=(unsigned long long)(i*N+1)/(unsigned long long)A;
B2=(unsigned long long)(i*N+1)%(unsigned long long)A;
if(B1<=A && B2==0)
{
out<<B1;
return 0;
}
}
return 0;
}
