Cod sursa(job #1984668)

Utilizator ImbuzanRaduImbuzan Radu ImbuzanRadu Data 25 mai 2017 17:19:18
Problema Invers modular Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("inversmodular.in");
ofstream g("inversmodular.out");


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

int main()
{
    long long int a,b,c,x,y,d=1,n;
   f>>a>>b>>c;
   euclid(a,b,d,x,y);
   /*if(c%d!=0)
   {
       g<<0<<" "<<0<<'\n';
   }else*/
   if(x<0)
    x=x*(-1);
   g<<x;
    return 0;
}