题意: 给定 a b n找到满足ax+by=n 的x,y 令|x|+|y|最小(等时令a|x|+b|y|最小) 分析: 算法一定是扩展欧几里得. 最小的时候一定是 x 是最小正值 或者 y 是最小正值 (简单的证明应该是分x,y 符号一正一负,和x,y符号都为正来考虑) 扩欧解的方程为 ax+by = gcd(a, b) 先简化问题,等价为扩欧求的是 a'x+b'y = 1 则原方程等价为 a'x+b'y = n' (a, b, n 全部除以gcd(a, b) ) 先解x为最小正值的时候 x =…
Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following: Choose k different positive integers a1, a2, …, ak. For some non-negative m, divide it by ev…