Cod sursa(job #1784416)

Utilizator elffikkVasile Ermicioi elffikk Data 20 octombrie 2016 00:04:56
Problema Invers modular Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
using namespace std;

main() {
    ifstream cin("inversmodular.in");
    ofstream cout("inversmodular.out");
    long long A, N, X, i = 2;
    cin>>A>>N;
    if (A == 1) {
        cout<<1;
    } else {
        while ( (i*N+1)%A > 0) i++;
        cout<< (i*N+1)/A;
    }
}