Cod sursa(job #2859870)
Utilizator | Data | 2 martie 2022 08:55:19 | |
---|---|---|---|
Problema | Invers modular | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
using namespace std;ifstream f("inversmodular.in");ofstream g("inversmodular.out");void h(int a,int b,int &x,int &y){if(b==0){x=1;y=0;return;}int m,n;h(b,a%b,m,n);x=n;y=m-n*(a/b);}int main(){int a,b,x,y;f>>a>>b;h(a,b,x,y);if(x<=0){x=b+(x%b);}g<<x;}