Cod sursa(job #2744953)

Utilizator Tudor06MusatTudor Tudor06 Data 25 aprilie 2021 16:30:45
Problema Invers modular Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <iostream>
#include <fstream>

using namespace std;

void euclid( int a, int b, long long& x, long long& y ) {
    if ( b == 0 ) {
        x = 1;
        y = 0;
    } else {
        long long x0, y0;
        euclid( b, a % b, x0, y0 );
        x = y0 % m;
        y = x0 - ( a / b ) * y0;
    }
}
int main() {
    ifstream fin( "inversmodular.in" );
    ofstream fout( "inversmodular.out" );
    int a, b;
    long long x, y;
    fin >> a >> b;
    euclid( a, b, x, y );
    fout << ( x + b ) % b;
    return 0;
}