这个问题可以使用一种被称为“完全混淆”的方法来解决。在密码学中,完全混淆是一种能将输入值唯一映射到输出值,并且同时保持输出的随机性的方法。对于你的问题,我们可以使用一种被称为“线性同余生成器”的方法。
线性同余生成器 (Linear congruential generator, LCG) 是一种伪随机数生成算法。它的公式如下:
X_{n+1} = (aX_n + c) mod m
这里的 X 是一个序列,n 是当前步数。a, c 和 m 是你选定的参数,它们需要满足一定的条件才能确保你得到一个好的混淆结果。
在你的情况下,我们可以将 m 设为 10^8,然后选择合适的 a 和 c。最终你将得到一个可以将 0-1 亿的数字映射到 0-1 亿的函数。
具体的参数选择你可以参考 Donald Knuth 在《计算机程序设计艺术》中给出的推荐值。他建议选择 m 为 2 的幂,a 为 m 的倍数加 1,c 为一个奇数。
请注意,由于线性同余生成器的输出是伪随机的,所以它并不能保证输出完全没有规律。如果你需要完全无规律的输出,可能需要使用一种更复杂的混淆方法,或者使用一种真正的随机数生成器。
Linear congruential generator (LCG) is a pseudorandom number generation algorithm that generates a sequence of numbers based on the linear congruence equation:
X_{n+1} = (aX_n + c) mod m
Here, X is the sequence, n is the current step, and a, c, and m are parameters that you choose. However, they need to satisfy certain conditions to ensure good mixing of the output.
In your case, you can set m to be 10^8 and choose suitable values for a and c. This will give you a function that maps numbers from 0 to 100 million to another number in the same range.
For selecting the parameters, you can refer to the recommended values given by Donald Knuth in "The Art of Computer Programming." He suggests choosing m as a power of 2, a as a multiple of m plus 1, and c as an odd number.
It is important to note that since LCG generates pseudorandom numbers, the output is not truly random and may exhibit some patterns. If you require truly random output without any patterns, you may need to use a more complex mixing method or a true random number generator.