Cod sursa(job #2539092)

Utilizator nicolaee2Martinescu Nicolae nicolaee2 Data 5 februarie 2020 16:50:07
Problema Invers modular Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include<iostream>
#include<fstream>
#include <bits/stdc++.h>
#define MOD 30211
#define NMAX 2005
#include <string>
using namespace std;

int b,n;

ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");

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

int main()
{
   fin>>b>>n;
   int x,y;

   invers(b,n,x,y);
   fout<<x;

}