Cod sursa(job #1881590)

Utilizator bleo16783FMI Bleotiu Cristian bleo16783 Data 16 februarie 2017 16:40:52
Problema Invers modular Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.42 kb
#include <fstream>
using namespace std;
#define ll long long
ll a,n,x,y;
void E(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1;
        y=0;
    }
    else
    {
        ll x0,y0;
        E(b,a%b,x0,y0);
        x=y0;
        y=x0-(a/b)*y0;
    }
}
int main()
{
    ifstream f("inversmodular.in");
    f>>a>>n;
    E(a,n,x,y);
    ofstream g("inversmodular.out");
    g<<x;
    return 0;
}