如何预测C中的rand()函数? [英] How to predict rand() function in C?

查看:141
本文介绍了如何预测C中的rand()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作预测序列中下一个随机数的oracle。我有一系列随机生成的数字。



我尝试过:



我知道我应该采用线性方式。

解决方案

根据随机数序列的值范围,你可能是一个失败者 - 兰德它不仅具有算法,还具有种子值,该种子值通常在应用程序的某个点从系统时钟初始化。取决于种子,算法开始的位置以及它产生的序列。即使范围仅为1,2或3,除非您知道算法和起始种子,以及已经从随机序列中取出了多少项,否则可能序列的数量会快速增长。


Quote:

我尝试使oracle预测序列中的下一个随机数。



注定会失败。

Nicolas Cage是唯一能够做到这一点的人(见下一部电影)。


I try to make oracle which predicts next random number in a sequence. I have an array of random generated numbers.

What I have tried:

I know that i should do it linear way.

解决方案

Depending on the range of values for your random number sequence, you are probably on a loser - rand doesn't just have an algorithm, it also has a seed value which is normally initialized from the system clock at some point in the application. Depending on the seed, where the algorithm "starts" and thus the sequence it produces. Even if the range is just 1, 2, or 3 the number of possible sequences rapidly grows out of any possible prediction unless you know the algorithm, and the starting seed, and how many items have been "taken" from the random sequence already.


Quote:

I try to make oracle which predicts next random number in a sequence.


that is doomed to fail.
Nicolas Cage is the only one able to do this (see movie Next).


这篇关于如何预测C中的rand()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆