裴蜀定理(针对于多元一次不定方程的求解)

裴蜀定理指出,对于整数a、b和它们的最大公约数d,总存在整数x、y使得ax + by = d。本文探讨了该定理的证明过程,通过同余方程的性质揭示了ax + by的最小正整数解与最大公约数之间的关系。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

裴蜀定理的基本内容是】

若a,b是整数,且gcd(a,b)=d,那么对于任意的整数x,y,ax+by都一定是d的倍数,特别地,一定存在整数x,y,使ax+by=d成立。

如何证明这个定理呢?

  1. 假设c是ax+by的最小正整数解,也即是ax+by=c,d=(a,b)
  2. 根据最大公约数的性质及同余方程的性质,可以知道:d|a,d|b,d|(ax+by)
  3. 假设r是a%c的余数,t是a/c的整除商,那么就有r=a-t*c=a-t*(ax+by)(因为c是ax+by的最小正整数解)
  4. 整理可得r=a(1-tx)+bty,将1-tx与ty看作一个整体,就可以得出r也是a与b的线性组合,那么同样可以表示为ax+by的形式
  5. 因为c已经是ax+by的最小正值,所以r只能为0
  6. 因此a%c=0,即c|a,c|b,可推出c|d,因为c是最小正整数解,所以c=d 

#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <queue>
#include <map>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <cstring>
#include <cmath>
#define DETERMINATION main
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#define lldin(a) scanf("%lld", &a)
#define println(a) printf("%lld\n", a)
#define print(a) printf("%lld ", a)
#define reset(a, b) memset(a, b, sizeof(a))
#define debug std::cout<<"procedures above are available"<<"\n";
#define BigInteger __int128
const int INF = 2e9 + 2;
const double PI = acos(-1);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
//template<typename T>
//inline BigInteger nextBigInteger()
//{
//    BigInteger tmp = 0, si = 1;char c;    c = getchar();
//    while (!isdigit(c))
//{if (c == '-')si = -1;c = getchar();}
//    while (isdigit(c))
//    {tmp = tmp * 10 + c - '0';c = getchar();}
//    return si * tmp;    
//}            
//std::ostream& operator<<(std::ostream& os, __int128 T)
//{
//    if (T<0) os<<"-";if (T>=10 ) os<<T/10;if (T<=-10) os<<(-(T/10));
//    return os<<( (int) (T%10) >0 ? (int) (T%10) : -(int) (T%10) ) ;
//}
//void output(BigInteger x)
//{
//    if (x < 0)
//    {x = -x;putchar('-');}
//    if (x > 9) output(x / 10);
//    putchar(x % 10 + '0');
//    }
/**The doorway has been blocked,whether to knock it out or find another way is a vital choice**/
/**Last Remote**/
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a%b);
}
int DETERMINATION()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0), std::cout.tie(0);
	ll n;
	std::cin >> n;
	ll k;
	std::cin >> k;
	ll ans = k;
	for (int i = 1; i <= n - 1; i++)
	{
		ll tmp;
		std::cin >> tmp;
		tmp = abs(tmp);
		ans = gcd(tmp, ans);
	}
	std::cout << ans << "\n";
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值