Pagini recente » Cod sursa (job #2729228) | Cod sursa (job #2395875) | Cod sursa (job #724529) | Cod sursa (job #1743904) | Cod sursa (job #2691045)
#include <stdio.h>
void calculez( int a, int b, int *x, int *y )
{
if( b == 0 ){
*x = 1;
*y = 0;
} else {
int x0, y0;
calculez( b, a % b, &x0, &y0 );
*x = y0;
*y = x0 - ( a / b ) * y0;
}
}
int main()
{
int a, n, x, y;
FILE *fin = fopen( "inversmodular.in", "r" );
fscanf( fin, "%d %d", &a, &n );
fclose( fin );
calculez( a, n, &x, &y );
FILE *fout = fopen( "inversmodular.out", "w" );
fprintf( fout, "%d", x );
fclose( fout );
return 0;
}