[Extended Euclid] [Patch the Square Problem]

Questions about piecing together squares are generally related to Euclid or extended Euclid, at least generally to the greatest common divisor [I didn't say anything.. I didn't! I'm not!

https://acm.ecnu.edu.cn/contest/69/problem/A/

The meaning of the question: Given a square [the side length is n], and several rectangles [the length is x, the width is y], ask if you can piece together a large square [among which at least one rectangle must be used and the small square must be used]

First of all, if you want to piece together a square, you must have ax+by=n to have a solution

Prove: Let the side length of the large square be X, then the patchwork process must have X=k1x+m1y+n and X=k2x+m2y [the two equations correspond to the row containing the small square and the row not containing the small square respectively], Then we can get (k2-k1)x+(m2-m1)y=n by sorting, that is, ax+by=n has a solution, and the proof is obtained.

From extended Euclid, we know that when n is a multiple of gcd(x,y), there must be a solution, otherwise there must be no solution.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324640692&siteId=291194637