Thought of by indefinite equation--the selection of number theory

Source: Internet
Author: User

The so-called two yuan an indefinite equation, refers to the $x,y$, the shape of the $ax+by=c$ equation

Here we agree that the $a,b,c$ are integers.

So the question we have is: how do we judge this equation to have a solution?

Bezout theorem: Set $a,b,d$ are integers, and $ (A, B) =d$, there is $u,v$ make $ua+vb=d$

Proof: by $ (A, B) =d$ know $ and d|a and d|b$, then there is $d|ua+vb$

? Remember that the minimum positive value for $ua+vb$ is $s$, then $d|s$

? Do band Rest Division for a: $, and both are integers a=qs+r (0\leq r<s, and Q and R are integers) $

? Then $r=a-qs=a-q (UA+VB) = (1-qu) A + (-QV) b$, so R is a B linear combination (you can interpret the linear combination as an integer z can be represented as ax+by (both integers))

? and S is the minimum positive value of $ua+vb$ and $0\leq r<s$, so $r=0$, that is $a=qs$

? So $s|a$

? The same can be proven $s|b$

? So $ is s| (A, B) is s|d$ and $d|s$ known $d=s$

After we have defined the Bezout theorem, we can conclude that there is a condition for the solution of an indefinite equation of two yuan: $GCD (A, b) |c$

Proof: Set $D=GCD (A, B), a=a_1d,b=b_1d,c=c_1d$, then the original equation can be converted to $A_1X+B_1Y=C_1,GCD (a_1,b_1) =1$

? Known by the bezout theorem, there is an integer $x_0,y_0$, which makes $a_1x_0+b_1y_0=1$

? So $a_1 (x_0c_1) +b_1 (y_0c_1) =c_1$

? Thus the original equation has a set of integer solutions $x=x_0c_1,y=y_0c_1$

We have constructed a set of solutions to the equation in just the proof, it is obvious that if the solution is not feasible according to the above method, we must think of a method to find out a set of solutions to the indefinite equation.

In the above proof process, in addition to known quantity, we repeatedly mentioned another number $gcd (A, b) $

Let's see if we can find some clues from this number.

First solve this equation $ax+by=gcd (A, b) $

(1) If $b=0$, then $GCD (A, B) =a$, the original equation is $a x+0 y=a$, obviously $x=1,y=0$

(2) If $b\neq 0$, then $GCD (b) =gcd (b,a\ mod\ B) $

? This allows you to know $ax+by=bx_0+ (a\ mod\ b) y_0=bx_0+ (a-a\ div\ b*b) y_0=ay_0+b (x_0-a\ div \ b*y_0) $

So $x=y_0,y=x_0-a\ div\ b*y_0$

And we already know the value of the last $ with x_0 and y_0$

So go up and down the floor and push up.

Since all processes are based on the $GCD (A, b) $, this method is called extended Euclidean

The code is as follows

1#include <iostream>2#include <string>3#include <string.h>4#include <stdio.h>5#include <algorithm>6#include <vector>7#include <queue>8#include <map>9 using namespacestd;Ten   One voidEXGCD (intAintBint&x,int&y) A { -     if(b==0) {x=1; y=0;return;} -EXGCD (b,a%b,x,y); the     inttmpx=x,tmpy=y; -X=tmpy;y=tmpx-(A/b) *Tmpy; - } -   + intMain () - { +     intb; ACin >> a >>b; at     intx, y; - EXGCD (a,b,x,y); -cout << x <<" "<<y; -     return 0; -}


If the indefinite equation is $AX+BY=K*GCD (A, b) $, then directly on the basis of the $x,y$ obtained $k$ can be

After we have found out a set of solutions to the original indefinite equation, can we use it to introduce all the solutions?

Suppose that the solution we currently find is $ (x_0,y_0) $, the next set of solutions is $ (x_0+d_1,y_0+d_2) (where d_1 is the smallest positive integer that satisfies the condition) $

Then $ A (x_0+d_1) +b (y_0+d_2) =c,ax_0+by_0=c$

Brought into $ad_1+bd_2=0$, i.e. $\frac{d_1}{d_2}=-\frac{b}{a}$

$\FRAC{D_1}{D_2}=-\FRAC{\FRAC{B}{GCD (A, B)}}{\frac{a}{gcd (A, b)}}$

Thus two yuan the general solution of the $ax+by=c$ of an indefinite equation can be expressed as

$ $x =X_0+K*\FRAC{B}{GCD (A, B)},y=y_0-k*\frac{a}{gcd (A, b)}$$, where $k\in z$

Thought of by indefinite equation--the selection of number theory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.