LoginSignup
2
2

More than 5 years have passed since last update.

a*x + b*y = gcd(a,b) を解くプログラム

Last updated at Posted at 2015-02-24

何名かの方が最大公約数を求めるプログラムを作っていたので、その応用問題です。受験数学とかで見たことあるのでは?

整数 a, b に対して、以下を満たす整数 x, y を求めよ。

ax + by = gcd(a,b) 
  • ベズーの等式(Bézout's identity)、というようです。
    でも identity 恒等式でなく equation 方程式なんだけど……

  • 解は無限にあるので、1組の $(x,y)$ を求めればよいです

  • びっくりするくらい簡単なので、せめて5分間だけでもアタマをひねってみてください

ヒント

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2