跳到正文

算法·理论

整数的离散性

std__int64_t约 8 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 8 分钟

版本

  1. v3当前
  2. v2
  3. v1

前言

这是我和盟友两位五年级蒟蒻合作的数论合集第一篇文章,大佬们不喜勿喷,感谢您的收看。

不等式整数解

一个集合离散是指集合中任意两个不同的数之间都距离会有一个大于零的的下界,请判断整数集,实数集,有理数集,自然数集是否离散。

  • 整数集和自然数集中任意两个不同的数之间的距离都大于一,故离散。
  • 实数集合有理数集中任意两个不同的数之间都会存在一个新的实数(有理数),所以两个不同的实数(有理数)之间的距离是没有大于零的下界的,故不离散,故稠密。

那么在任意一个有限的范围中,整数的个数是有限的,所以找到未知数的范围再逐一验证就一定能找到解。

离散的集合可以将集合中的所有数从小到大一个接一个的排成一排,那么相邻两个数之间不存在别的数属于该集合。如果一个元素在相邻两个集合中的数之间时,则它不属于该集合,证明整数和完全平方数时可以使用这种方法,被称为“卡范围”。

例题一

题目

一个正整数的立方为四位数,四次方为六位数,且用到的十个数字互不相同,求这个数。

将它设出来后,可得到关于四位数与六位数的不等式,得到未知数 nn 的范围 18≤n≤2118\le n \le 21,根据末尾判断 n=18,19n=18,19,逐一枚举即可

完整解答

设这个数为 nn,由题意

1000≤n3≤9999<100000≤n4≤9999991000\le n^3\le9999<100000\le n^4\le999999

解得

18≤n≤2118\le n\le 21

又

203≡204≡0(mod10)20^3 \equiv 20^4\equiv 0\pmod{10}213≡214≡1(mod10)21^3\equiv 21^4\equiv 1\pmod{10}∴n=18,19\therefore n=18,19

经枚举,n=18n=18

如果你知道整除特征,你就能一眼看出 n=19n=19 不行,读者可以自行学习。

例题二

题目

求使不等式 917<nn+k<815\frac{9}{17}<\frac{n}{n+k}<\frac{8}{15} 对唯一整数 kk 成立的最大整数 nn。

多元对称有序枚举

在多元对称有序枚举时,可以将未知数排序,从小到大(从大到小)进行枚举,每次枚举时,可以稍微卡一下最大数(最小数)的范围,来保证有限枚举。

例题一

题目

求方程 1a+1b+1c=12\frac{1}{a} + \frac{1}{b} + \frac{1}{c} = \frac{1}{2} 的正整数解数量。

由于原式是对称式,那么不妨设 a≤b≤ca \le b \le c,易知 1a<12≤3a\frac{1}{a} < \frac{1}{2} \le \frac{3}{a},得 3≤a≤63 \le a \le 6,枚举 aa 得到 1b+1c=xy\frac{1}{b} + \frac{1}{c} = \frac{x}{y},两边同乘 ybcybc 后因式分解求解即可。

完整解答

不妨设

a≤b≤ca \le b \le c

易知

1a<12≤3a\frac{1}{a} < \frac{1}{2} \le \frac{3}{a}∴3≤a≤6\therefore 3 \le a \le 6

若 a=3a = 3

∴1b+1c=16\therefore \frac{1}{b} + \frac{1}{c} = \frac{1}{6}∴bc−6b−6c=0\therefore bc - 6b - 6c = 0∴(b−6)(c−6)=36\therefore (b - 6)(c - 6) = 36∴{a=3,3,3,3,3b=7,8,9,10,12c=42,24,18,15,12\therefore \begin{cases} a = 3, 3, 3, 3, 3 \\ b = 7, 8, 9, 10, 12 \\ c = 42, 24, 18, 15, 12 \end{cases}

若 a=4a = 4

∴1b+1c=14\therefore \frac{1}{b} + \frac{1}{c} = \frac{1}{4}∴bc−4b−4c=0\therefore bc - 4b - 4c = 0∴(b−4)(c−4)=16\therefore (b - 4)(c - 4) = 16∴{a=4,4,4b=5,6,8c=20,12,8\therefore \begin{cases} a = 4, 4, 4 \\ b = 5, 6, 8 \\ c = 20, 12, 8 \end{cases}

若 a=5a = 5

∴1b+1c=310\therefore \frac{1}{b} + \frac{1}{c} = \frac{3}{10}∴9bc−30b−30c=0\therefore 9bc - 30b - 30c = 0∴(3b−10)(3c−10)=100\therefore (3b - 10)(3c - 10) = 100∴{a=5b=5c=10\therefore \begin{cases} a = 5 \\ b = 5 \\ c = 10 \end{cases}

若 a=6a = 6

∴1b+1c=13\therefore \frac{1}{b} + \frac{1}{c} = \frac{1}{3}bc−3b−3c=0bc - 3b - 3c = 0∴(b−3)(c−3)=9\therefore (b - 3)(c - 3) = 9∴{a=6b=6c=6\therefore \begin{cases} a = 6 \\ b = 6 \\ c = 6 \end{cases}

综上,共 6×6+3×3+1=466 \times 6 + 3 \times 3 + 1 = 46 组。

例题二

当上题中的三个数变为四个数时,枚举量会增加不少;如果 12\frac{1}{2} 变成让你求的几个数,你还会这么有耐心的枚举吗?

题目

(20072007,白俄罗斯数学奥林匹克)求所有的正整数 nn,使它能整除它的不同的四个因数之和。

建议先阅读下个版块的定义与性质。 如果这四个因数为 a1,a2,a3,a4a_1, a_2, a_3, a_4,那么不方便体现四个因数与 nn 的关系,在枚举因数时消不掉 nn,所以设四个因数为 na1,na2,na3,na4\frac{n}{a_1}, \frac{n}{a_2}, \frac{n}{a_3}, \frac{n}{a_4} 在枚举时就消掉了 nn,所以问题就变成了 1a1+1a2+1a3+1a4=k∈Z+\frac{1}{a_1} + \frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} = k \in \Z^{+}。简单放缩得 k=1,2k = 1, 2,然后逐一枚举即可。

完整解答

设 nn 的四个因数为 na1,na2,na3,na4\frac{n}{a_1}, \frac{n}{a_2}, \frac{n}{a_3}, \frac{n}{a_4}, 其中 a1,a2,a3,a4∈Z+,a1<a2<a3<a4a_1, a_2, a_3, a_4 \in \Z^{+}, a_1 < a_2 < a_3 < a_4,且 a1,a2,a3,a4∣na_1, a_2, a_3, a_4 \mid n。

∴[a1,a2,a3,a4]∣n\therefore [a_1, a_2, a_3, a_4] \mid n

由题意

n∣na1+na2+na3+na4n \mid \frac{n}{a_1} + \frac{n}{a_2} + \frac{n}{a_3} + \frac{n}{a_4}∴1a1+1a2+1a3+1a4∈Z+\therefore \frac{1}{a_1} + \frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} \in \Z^{+}

设

1a1+1a2+1a3+1a4=k∈Z+\frac{1}{a_1} + \frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} = k \in \Z^{+}1a1+1a2+1a3+1a4=k≤1+12+13+14<3\frac{1}{a_1} + \frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} = k \le 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} < 3∴k=1,2\therefore k = 1, 2

若 k=1k = 1

∴1a1+1a2+1a3+1a4=1\therefore \frac{1}{a_1} + \frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} = 1∴1a1<1<4a1\therefore \frac{1}{a_1} < 1 < \frac{4}{a_1}∴a1=2,3\therefore a_1 = 2, 3

若 a1=2a_1 = 2 由例题一的解,6∣n6 \mid n 或 20∣n20 \mid n。


若 a1=3a_1 = 3

1a2+1a3+1a4=23\frac{1}{a_2} + \frac{1}{a_3} + \frac{1}{a_4} = \frac{2}{3}

(省略枚举过程,毕竟简单,跟上一题一样。) 解得 6∣n6 \mid n 或 20∣n20 \mid n。


若 k=2k = 2 若 a3≤4a_3 \le 4,则 LHS≤1+12+14+15<1=RHS\text{LHS} \le 1 + \frac{1}{2} + \frac{1}{4} + \frac{1}{5} < 1 = \text{RHS},矛盾。

∴a1=1,a2=2,a3=3,a4=6\therefore a_1 = 1, a_2 = 2, a_3 = 3, a_4 = 6∴6∣n\therefore 6 \mid n

综上,6∣n6 \mid n 或 20∣n20 \mid n。

后记

原创不易,点个赞再走吧~~ 求管理员通过qwq 更多精彩,关注我们的合集

原文