前言
https://www.luogu.com.cn/article/f13raoak
正文
现代问题需要现代的解决方案。
我们要证明:任意自然数 都能通过四则运算得到 的倍数。
所以我们不妨设 。
考虑如下图灵机:
bool check(int a, int b, int c, int d) {
bool f[1 << 4][24] = {};
f[1 << 0][a] = true;
f[1 << 1][b] = true;
f[1 << 2][c] = true;
f[1 << 3][d] = true;
for (int S = 1; S < (1 << 4); S++) {
for (int T = (S - 1) & S; T > 0; T = (T - 1) & S) {
int U = S ^ T;
for (int x = 0; x < 24; x++) {
if (!f[T][x]) continue;
for (int y = 0; y < 24; y++) {
if (!f[U][y]) continue;
f[S][(x + y) % 24] = true;
f[S][(x - y + 24) % 24] = true;
f[S][(y - x + 24) % 24] = true;
f[S][(x * y) % 24] = true;
}
}
}
}
return f[(1 << 4) - 1][0];
}
int main() {
for (int a = 0; a < 24; a++)
for (int b = a; b < 24; b++)
for (int c = b; c < 24; c++)
for (int d = c; d < 24; d++)
while (!check(a, b, c, d));
return 0;
}显然原问题等价于证明这个图灵机会停机。而我们不难注意到这个图灵机确实会停机,于是得证。