Time for Computers to Take Over

Let x , y x, y be a pair of integers that satisfy the equation

233987973 x + 41111687 y = 1 233987973 x + 41111687 y = 1

What is the value of

( x m o d 41111687 ) + ( y m o d 233987973 ) ? (x \bmod{41111687}) + (y \bmod {233987973})?


If you think there is no answer or exist multiple answers to this problem, write 1 -1 .


The answer is 96602160.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Christopher Boo
Sep 19, 2016

This is not a complete solution. The following is the program to solve this problem.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from math import floor
from math import ceil

def bezout(a, b):
    q = (floor(a / b) if b > 0 else ceil(a / b))
    r = a - b * q
    if b % r == 0:
        return (1, -q)
    else:
        x, y = bezout(b, r)
        return (y, x - q * y)

a, b = 233987973, 41111687
x, y = bezout(a, b)
print(x % b + y % a)

Ivan Udovin
Jan 16, 2018

We can see, that equation in the statement has the next form:

a x + b y = g c d ( a , b ) a \cdot x + b \cdot y = gcd(a, b) (Bezout's identity)

To solve it we can use extended Euclidean algorithm. Using such algorithm we can found only one solution, but this equation has infinite amount of solutions. All solutions we can found in this way:

Let's suppose that the numbers x 0 x_0 and y 0 y_0 are a solution for our equation. We can found all solutions using such formula:

{ x = x 0 + k b g , y = y 0 k a g , \cases{ x = x_0 + k \cdot \frac{b}{g}, \cr y = y_0 - k \cdot \frac{a}{g}, } where g = g c d ( a , b ) g = gcd(a, b) and k Z k \in \mathbb{Z} .

For this statement all solutions can be found as following:

{ x = x 0 + k b , y = y 0 k a , \cases{ x = x_0 + k \cdot b, \cr y = y_0 - k \cdot a, }

And finally, we need to understand, that:

{ x x 0 ( m o d b ) , y y 0 ( m o d a ) \cases{ x \equiv x_0 \pmod{b}, \cr y \equiv y_0 \pmod{a} }

This is programmatic solution:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Extended Euclidean algorithm
def solve(a, b):
    if a == 0:
        return 0, 1
    x, y = solve(b % a, a)
    return y - b // a * x, x

a, b = 233987973, 41111687
x, y = solve(a, b)
print(x % b + y % a)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...