这题嘛,没有做,直接复制以前的代码过来,就提交了,顺利通过。
后来又看了一下。
这题我的猜想是,伪随机数在一个重复周期内的总和必然小于或等于 0 到 mod-1 的所有整数之和。(这个猜想也不知是否正确,欢迎有知情人士指出)
------------------------------ 原题如下 -------------------------------------------
Uniform Generator
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5562Accepted Submission(s): 2228
Problem 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 <= STEP, MOD <= 100000).
Output
For each line of input, your program should print the STEP value right- justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either "Good Choice" or "Bad Choice" left-justified starting in column 25. The "Good Choice" message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message "Bad Choice". After each output test set, your program should print exactly one blank line.
Sample Input
Sample Output
3 5 Good Choice
15 20 Bad Choice
63923 99999 Good Choice
Source
Recommend
JGShining
分享到:
相关推荐
python中uniform函数_Pythonuniform()函数使⽤⽅法⼊门 教程基础教程 Python uniform() 函数 描述 uniform() ⽅法将随机⽣成下⼀个实数,它在 [x, y) 范围内。 语法 以下是 uniform() ⽅法的语法: import random ...
针对鲁棒分块跟踪采用穷举的搜索策略以及对光照敏感等问题,提出了一种基于粒子群优化算法和Uniform LBP特征的分块跟踪方法。利用统一的局部二值模式(Uniform Local Binary Pattern)特征对光照的不变性以及计算...
Uniform_UBoot_S50-90
An Improved Uniform Identity Authentication Method.pdf
文档中详细的给出了 实现均匀设计的matlab代码,通过编写确认无误。
uniform.h,用于产生均匀分布的随机数。
发现网上对lbp降维的源码大多都是基于半径为1,采样点为8的尺度,本源码实现了不同尺度的降维工作,并提取了描述符,希望能给大家的科研工作带来便利。
在单样本人脸识别系统中,为了获得更好的人脸面部特征,提出了一种融合Uniform LBP特征和多流形判别分析(Discriminative Multi-Manifold Analysis,DMMA)的特征提取方法。对每幅人脸图像进行分块构成一个子集。...
matlab code for non uniform linear array phased array
Web表单是一个网站的重要方面,但theyrz在视觉方面往往被忽视。Uniforms可以帮助你增加一个华丽的外观和视觉效果。 例如单选按钮或选择下拉菜单,这些资源只能用简单的CSS,这通常是一件痛苦的事情。... 标签:Uniform
基于jQuery的表单美化插件:uniform
基于Uniform LBP和DMMA的单样本人脸识别.pdf
表单美化。很不错的效果。透明效果动态效果
Nonuniform sampling of nonbandlimited signals - IEEE
The main objective of this paper is to increase the complexity by novel schemes of mixing (reversible cellular automata) RCA and (non-uniform reversible cellular automata) NRCA. We apply set of ...
The purpose of this of IEC 61400 is to provide a uniform methodology that will ensure consistency and accuracy in the measurement and analysis of acoustical emissions by wind trubine generator systems...
统一资源定位符(URL,英语Uniform Resource Locator的缩写)也被称为网页地址,是因特网上标准的资源的地址。它最初是由蒂姆•伯纳斯-李发明用来作为万维网的地址的。现在它已经被万维网联盟编制为因特网标准RFC...
方开泰创立的均匀设计表程序,用来实现实验设计。
these are important file regarding Direction of arrival for Non uniform linear array.
本书围绕随机变量生成算法的预期复杂性展开。 它建立了一个理想的计算模型,引入了均匀有界期望复杂度的概念,并研究了计算复杂度的界线。