Cod sursa(job #1679699)

Utilizator razvandRazvan Dumitru razvand Data 8 aprilie 2016 10:22:17
Problema Invers modular Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>

using namespace std;

inline void gcd(int a, int b, int &d, int &x, int &y) {
    if (b == 0) {
        d = a;
        x = 1;
        y = 0;
    } else {
        int x0, y0;
        gcd(b, a % b, d, x0, y0);
        x = y0;
        y = x0 - (a / b) * y0;
    }
}

int main() {

    int x,y,d = 0;

    int a,b;

    a = 24;
    b = 15;
    int c = 147;

    gcd(a,b,d,x,y);

   //if(x <= 0)
    //x = b + x%a;

    cout << c << " " << d << " " << x << " " << y << endl;

    cout << x*(c/d);

    return 0;
}