src/day13.cpp
// Returns modulo inverse of a with respect to m using extended Euclid Algorithm.
Returns modulo inverse of a with respect to m using extended Euclid Algorithm.
Returns modulo inverse of a with respect to m using extended Euclid Algorithm .
long long inv(long long a, long long m) 
{ 
    long long m0 = m, t, q; 
    long long x0 = 0, x1 = 1; 
    if (m == 1) 
       return 0; 
    while(a > 1) 
    { 
        q = a / m; 
        t = m; 
        m = a % m, a = t; 
        t = x0; 
        x0 = x1 - q * x0; 
        x1 = t; 
    } 
    return x1 < 0 ? x1 + m0 : x1; 
}
long long inv ( long long a , long long m ) { long long m0 = m , t , q ; long long x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m , a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } return x1 < 0 ? x1 + m0 : x1 ; }
Returns modulo inverse of a with respect to m using extended Euclid Algorithm.
Returns modulo inverse of a with respect to m using extended Euclid Algorithm .
// Apply extended Euclid Algorithm  // q is quotient  // m is remainder now, process same as euclid's algorithm  // Make x1 positive 