```python
def solution(a, b, n):
    
    def extended_gcd(num1, num2):
        """
        Implements the Extended Euclidean Algorithm.
        Returns a tuple (gcd, x, y) such that num1*x + num2*y = gcd.
        """
        if num2 == 0:
            return num1, 1, 0
        
        gcd, x_prime, y_prime = extended_gcd(num2, num1 % num2)
        
        x = y_prime
        y = x_prime - (num1 // num2) * y_prime
        
        return gcd, x, y

    if a == 0 and b == 0:
        # If a and b are both 0, a solution only exists if n is also 0.
        # In that case, 0*x + 0*y = 0, and any (x, y) is a solution.
        # We can return a simple one like (0, 0).
        # The problem implies a solution always exists.
        return 0, 0

    # Find g = gcd(a, b) and coefficients x_prime, y_prime such that:
    # a * x_prime + b * y_prime = g
    common_divisor, x_prime, y_prime = extended_gcd(a, b)
    
    # The equation ax + by = n has a solution if and only if n is
    # divisible by gcd(a, b). We assume the problem guarantees this.
    
    # We have a*x_prime + b*y_prime = common_divisor.
    # To get a solution for ax + by = n, we scale by n / common_divisor.
    multiplier = n // common_divisor
    
    x = x_prime * multiplier
    y = y_prime * multiplier

    return x, y
```