返回题库

五位数:任意两位数字和两两不同

Pairwise Digit Sums II

专题
Algorithmic Programming / 算法编程
难度
L4

题目详情

设集合 AA 为所有 5 位正整数,使得其 5 个数字的所有两两和(共 (52)=10\binom{5}{2}=10 个)都互不相同。

例如,一个满足该性质的 3 位数是 174(其两两和 1+7=8、1+4=5、7+4=11 各不相同)。

xxyy 分别为 AA 中的最小元素与最大元素,求 yxy-x

Let AA be the set of 5 digit integers such that all pairwise sums of digits are unique. For example, a three digit number with this property is 174174. Let xx and yy be the minimal and maximal elements of AA, respectively. Find yxy - x.

解析

用程序穷举 10000..99999 可得到:

  • 最小 x=10247x=10247
  • 最大 y=98752y=98752

因此

yx=9875210247=88505.\boxed{y-x=98752-10247=88505}.