作业帮 > 英语 > 作业

英语翻译Uniform GeneratorTime Limit:1000MS Memory Limit:10000KTo

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/03/29 12:53:36
英语翻译
Uniform Generator
Time Limit:1000MS Memory Limit:10000K
Total Submissions:4115 Accepted:1950
Description
Computer simulations often require random numbers.One way to generate pseudo-random numbers is via a function of the form
seed(x+1) = [ seed(x) + STEP ] % MOD
where "%" is the modulus operator.
Such a function will generate pseudo-random numbers (seed) between 0 and MOD-1.One problem with functions of this form is that they will always generate the same pattern over and over.In order to minimize this effect,selecting the STEP and MOD values carefully can result in a uniform distribution of all values between (and including) 0 and MOD-1.
For example,if STEP=3 and MOD=5,the function will generate the series of pseudo-random numbers 0,3,1,4,2 in a repeating cycle.In this example,all of the numbers between and including 0 and MOD-1 will be generated every MOD iterations of the function.Note that by the nature of the function to generate the same seed(x+1) every time seed(x) occurs means that if a function will generate all the numbers between 0 and MOD-1,it will generate pseudo-random numbers uniformly with every MOD iterations.
If STEP = 15 and MOD = 20,the function generates the series 0,15,10,5 (or any other repeating series if the initial seed is other than 0).This is a poor selection of STEP and MOD because no initial seed will generate all of the numbers from 0 and MOD-1.
Your program will determine if choices of STEP and MOD will generate a uniform distribution of pseudo-random numbers.
Input
Each line of input will contain a pair of integers for STEP and MOD in that order (1
制服发电机
期限:1000MS极限:10000K记忆
总递交:4115接受:1950年
描述
计算机仿真结果往往需要随意数.一个方法是通过产生伪随机数字之间的函数形式
种子(x + 1)=[种子(x)+一步]%的模板
在“%”是模数运算符.
此功能将会产生伪随机编号(种子)介于0和MOD-1.有问题的功能的形式是叫他们永远产生同样的模式.为了尽量减少这种效果,选择步骤、国防部价值观仔细可以导致之间的均匀分布,包括所有值(0和MOD-1).
例如,如果一步= 3、国防部= 5,该函数将产生一系列的伪随机编号0、3、1号,4号,2个在一个不断重复周期.在这个例子中,所有的数字,包括0和MOD-1之间会产生每MOD次迭代的功能.注意,大自然的功能来产生相同的种子(x + 1)每次种子(x)发生意味着如果一个函数将产生所有编号介于0和MOD-1,它将产生伪随机编号一致与每个插件迭代.
如果步骤15例、国防部= 20,函数产生的系列0、15、10、5(或者任何其他如果初始种子重复系列除了0).这是一个贫穷的一步选择、国防部因为最初没有种子将产生所有的数量从0和MOD-1.
如果你的程序的选择将决定步骤、国防部将会产生一个均匀分布的伪随机编号.
输入
每一行输入将会包含一个对整数步、国防部按照这个顺序(1 < < = =一步,MOD 100000).
输出
在每一行输入,你的程序应该打印了一份价值right-justified步骤1至10日在列纵队right-justified国防部价值,或者11通过20个“好”或“坏的选择,选择“left-justified开始于柱25.“好选择”的信息应该被打印时的选择、国防部将产生所有步骤,包括数字0和MOD-1之间产生当国防部数字.否则,你的程序应该打印信息“坏的选择.”每个输出的测试集之后,你的程序应该准确印刷只留下一行.